Remove comments and blank lines from files

If you want to remove all the comment lines and the blank lines from a file to see the only active lines, just use sed as below:

sed '/^ *#/d; /^ *$/d'  filename

You can also do it with alternate methods like that:

grep -v ' *#' filename | grep -v '^ *$'

but sed is better.







You must be login first or sign-up for an account to post comments.

Maybe you should look at these also: