View conf file without comments

6 01 2010

Short and sweet entry to start 2010.  Some linux configuration files are pretty long and really include very few directives, a prime example is squid.conf (mine is currently an almighty 4898 lines!).  Most of these lines are comments and if we were so inclined we could probably copy the file without comments and sort the wheat from the chaff (of the 4898 lines, my squid.conf actually only uses 68 lines!)  I use the following to display or pipe the file without any comments:

grep ^[^#] /usr/local/squid/etc/squid.conf

or

grep ^[^#] /usr/local/squid/etc/squid.conf > tmp

This shows only the directives.

Alternatively we could redo the grep only this time show 2 of lines of comments before the directive using:

grep -B 2 ^[^#] /usr/local/squid/etc/squid.conf

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: