Showing results for 
Search instead for 
Did you mean: 

cat or more

Go to solution
A.G.M. Velthof
Valued Contributor

cat or more

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

Patrick Wallek
Honored Contributor

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')

A.G.M. Velthof
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