Friday, December 5, 2008
Delete blank lines in vi editor
Simple but useful vi editor tip.
Q. How can I delete any blank lines within a file in vi editor?
Ans:
In escape mode type
:g/^$/ d
And all your blank lines should be removed !!
Other ways of removing blank lines from a file using grep, awk and sed
$ grep -v '^$' file
$ grep '.' file
$ sed '/^$/d' file
$ sed -n '/^$/!p' file
$ awk NF file
$ awk '/./' file
Labels:
Bash,
bash shell newbie,
vi editor tips,
vi handy commands,
VIM
Subscribe to:
Post Comments (Atom)
© Jadu Saikia www.UNIXCL.com
1 comment:
Thank you, it was very helpful.
Post a Comment