- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: cat or more
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2014 05:06 AM - last edited on 07-23-2014 08:19 PM by Lisa198503
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 "#"
Thanks, Alfons
P.S. This thread has been moved from HP-UX>System Administration to HP-UX > languages. -HP Forum Moderator
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2014 06:42 AM
07-23-2014 06:42 AM
SolutionIf 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')
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2014 06:52 AM
07-23-2014 06:52 AM
Re: cat or more
Thanks Patrick,
just what I needed.
Groeten, Alfons
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2014 07:21 AM
07-23-2014 07:21 AM
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