[Ilugc] linux tips - stripe down comment lines from config files

  • From: girishvenkatachalam@xxxxxxxxx (Girish Venkatachalam)
  • Date: Tue Jul 27 12:57:02 2010

On Tue, Jul 27, 2010 at 12:54 PM, Girish Venkatachalam
<girishvenkatachalam@xxxxxxxxx> wrote:

On Tue, Jul 27, 2010 at 11:42 AM, Raja Chinnathambi
<kumar.craja@xxxxxxxxxxx> wrote:
Dear friends,

The following commands can be used to view the configuration files lines
excluding comment lines.

[guest@localhost ~]$ sudo grep -v "^#\|^$" /etc/squid/squid.conf | nl

[guest@localhost ~]$ sudo sed '/^#/d;/^$/d' /etc/squid/squid.conf | nl

note : This commands will remove the comment lines begin with # and empty 
lines.

If you want to remove any comment line begins that begins with any other
character add the REGEX to remove those lines.

$ grep -v '^#$' /etc/squid/squid.conf | vim -

or even

$ grep -v '^#$' /etc/squid/squid.conf | less


Sorry I was too fast.

My stuff will not remove empty lines. But you don't need sudo.

This is pretty good as it is.

-Girish

Other related posts: