Showing results for 
Search instead for 
Do you mean 

cat or more

Go to Solution
Valued Contributor

cat or more

[ Edited ]

Hello to all,


can anyone help me with the command to list the content of a file without lines starting with a "#"


Thanks, Alfons


P.S. This thread has been moved from HP-UX>System Administration to  HP-UX > languages. -HP Forum Moderator

Honored Contributor [Founder]

Re: cat or more

If you just want to omit lines with the '#' sign in the first column then this will do:


grep -v ^# /some/file


You can also pipe the output to 'more' as well.


grep -v ^# /some/file | more


If you want to list a file without ANY comment lines or blank lines, then try the following:


awk 'NF && ! /^[[:space:]]*#/' /some/file


You can also set the above as an alias so it is easier to use.  For example:


alias noc="awk 'NF && ! /^[[:space:]]*#/'"


Once the alias is set, you can just do:


noc /some/file



(By the way 'noc' means 'no comment')

Valued Contributor

Re: cat or more

Thanks Patrick,


just what I needed.


Groeten, Alfons

Valued Contributor

Re: cat or more

And to add to Patrick's solution, the noc alias is a true filter and can be used to read a file or accept stdin, like this:


noc /some/file

swlist -l patch | noc