Aug 8, 2012

Display uncommented lines of a file

As you must be aware that in any configuration file under Linux OS, there is hundreds of lines, most of them are commented with explanations. Therefore going though such files takes time to locate the line we are looking for.

I use the command below to remove all the commented lines and blank lines by combining two commands using pipe '|'. In my case the comments are marked with #.

grep -v "^#" | grep -v "^$"

The grep -v "^#" filename will remove the commented line.
The grep -v "^$" will remove the blank lines.

No comments:

Post a Comment