I have some long configuration files to go through, and I would like to see just what is actually active in the
.conf file, without any of the
# tags. What can I use to output the lines without a
# on it? I'm running Debian Wheezy with this command.
If the file is named
The net effect is that, if you have a file with contents like the following:
This regular expression will fail to match the first and third lines, because the first character at the start of lines 1 and 3 is in fact a
The regular expression will then succeed to match the remainder of the lines, because the first character at the start of lines 2 and 4 is indeed not a
Building on our success so far, you can also match lines such as:
(Notice that there is whitespace (tabs or spaces) in front of the comment, and since it's still a comment, we don't want it!)
by using the following:
So now we have:
You need to quote the # because your shell may interpret that as a comment as well.
The grep will remove any line with # on it. This may not be what you want. What may be more useful is removing the comments. You can use sed, or the 'Stream EDitor'. This may give you what you want.
The regular expression says "find from a comment character to the end of the line, and remove it" then pipe to less to read it more easily.
If the comments are always in the first column, you can use the method as written by @somequixotic, which only shows lines where there is no comment in the first column.