Display files without empty lines or comments

     

Paste the following in your shell:

cat << EOF >> ~/.bashrc
alias nocom='sed -e "/^\s*#/d" -e "/^\s*$/d"'
EOF

This sets up an alias, so that you don’t have to memorize it (which is impossible to begin with).

If you want this to be available for all new users, also add this to the /etc/skel/.bashrc file (tested on CentOS):

sudo cat > /etc/skel/.bashrc
alias nocom='sed -e "/^\s*#/d" -e "/^\s*$/d"'
EOF

Open a new session, and you’ll have the new nocom command. Then you can just

nocom /etc/foobar.conf

Cheers.