By blank or empty, I mean a line has no other than a single \n.
Originally, I thought this grep was the shortest solution:
grep -v ^$
But this answer definitely is the winner, with only 6 characters:
grep .
I am also looking for a command that has a special designed option just to remove blank lines, the only one I have come across is a command called dog., with -s or --squeeze-blank, which claims that “dog is better than cat.”
Using sed or awk or dog, when grep looks so much better as a solution, doesn’t make much sense. I don’t think there is a command solely for removing empty lines, but if you have ever seen one, please point me at the direction, I’d love to see one.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.