Filter configfiles from comments

Posted on November 17, 2006 in Linux

Somtimes you only want to see configuration in a config-file, to filter out every blank line and every comment line a simple:


egrep -v '^$|^#' something.conf
  |    |  | | '-> a  mesh at the beginning of line
  |    |  | '-> or
  |    |  '-> from start to end ... nothing -> blank line
  |    '-> do not show ... containing
  '-> to match against regular expressions

will do the work.

Edit:

Found another way:

grep ^[^#]

Also filters comments and blank lines (but no spaces and tabs).