bash shell – Tip of the Week: Those pesky comments!

Have you grown tired of going through lines and lines of comments in a configuration file, when all you want to see is what parameters are actually set?

Are you tired of using ‘grep -v‘ to eliminate the lines you don’t want to see?

Well, this handy little alias I’ve called nocomm in your .bash_profile can help.

Somewhere in your home bash profile ~/.bash_profile, create an inbuilt function and then alias it, like this:
       grep -v ^# $1 | grep -v ^$

alias nocomm=grepvalues

… the alias becomes active at the next login (or immediately, if you source the file like this ‘. ~/.bash_profile‘)

The alias works by not showing any line beginning with a comment, nor any blank lines, like this:

[root@asus ~]# nocomm /etc/sysconfig/nfs



About Michael Abboud

Linux / Unix Technical Specialist
This entry was posted in Linux / Unix Tips and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s