Saturday, November 1, 2008

Listing the uncommented

When working with configuration files, we are usually dealing with hundreds of lines, sometimes thousands of lines. There is an easy way for us to list only the uncommented lines. This is useful to check whether the setting that we have done is correct.

To show only the uncommented line for file.conf (this is for the configuration files that use # as comment) :

  • $ grep -v ^# file.conf | grep -v ^$
  1. "grep -v ^#" means list out everything that do not start with #
  2. "grep -v ^$" means list out everything that do not start with blank space

No comments: