Wednesday, March 19, 2008

Removing blank line from file

Using sed.
$ sed '/^$/d' withblankline.txt > withoutblankline.txt
Using grep.
$ grep -v '^$' withblankline.txt > withoutblankline.txt

Use following for loop (shell script) to remove all blank lines from all files stored in /home/prabhat/data directory:

#!/bin/sh
files="/home/prabhat/data/*.txt"
for f in $files
do
sed '/^$/d' $i > $i.out
mv $i.out $i
done

No comments:

SHOW ENGINE INNODB STATUS

  The SHOW ENGINE INNODB STATUS command in MySQL provides detailed information about the internal state of the InnoDB storage engine. This ...