Sunday, 13 April 2014

Quickly view config files on Linux with no comments



There are many occasions when I am configuring new software on Linux and the configuration files are full of comments. While these have admittedly useful information what I want is to quickly view only the configuration that is currently set. Then I can see what I need to change or add in the file.

The solution is to use grep with regular expression ^[^#] which matches the first character of any line when that character is not equal to #. Lines without characters do no match so are also not displayed.

$ grep ^[^#] <path to file>

Example

$ grep ^[^#] /etc/resolv.conf

No comments:

Post a Comment