Instruction:
Before running these command make backup of your original file.
# cat foo
hello
hi
this
that
#sed -i '/^$/d'
foo
# cat foo
hello
hi
this
that
This tells sed
to delete every line matching the regex ^$ i.e. every empty line. The -i flag
edits the file in-place, if your sed doesn't support that you can write the
output to a temporary file and replace the original:
#sed '/^$/d'
foo > foo.tmp
#mv foo.tmp foo
How to Hide lines starting with # from file
# cat file
Testing
#Just testing
# egrep -v '^#|^$' file
#cat file
Testing
0 comments:
Post a Comment