Pages

Monday, March 8, 2010

View Config Files Without Comments

I've been using this grep invocation to trim comments out of config files. Comments are useful, but difficult to get only the active configuration entries which will be less than 20 or 25 lines from a very long file.

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

The regex ^[^#] matches the first character of any line, as long as that character that is not a #. Because blank lines don't have a first character they're not matched either, resulting in a nice compact output of just the active configuration lines.

Your comments are always welcome.

Regards
Shiroy Pigarez

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.