07-23-2014 05:06 AM - last edited on 07-23-2014 08:19 PM by Lisa198503
Hello to all,
can anyone help me with the command to list the content of a file without lines starting with a "#"
P.S. This thread has been moved from HP-UX>System Administration to HP-UX > languages. -HP Forum Moderator
Solved! Go to Solution.
07-23-2014 06:42 AM
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:
(By the way 'noc' means 'no comment')