Wednesday, February 2, 2011

4) Deleting blank lines from a file using "grep"

For thos who are not familiar with awk, but still want a quick and easy way of removing blank lines from a flat ascii file, remember that the use of 'cat' in conjuction with 'grep' is just as effective.

$ cat file1 | grep -v '^$' >file2
$ mv -f file2 file1

No comments:

Post a Comment