- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk question regarding /[:space:]/ and REs
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
Forums
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
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
09-26-2001 04:41 AM
09-26-2001 04:41 AM
(Yes, I am preprocessing Oracle PL/SQL code).
I am using
cat FILE |awk ' /^[:space:]*--/ {printf "%6d: %s\n", NR, $0}'
but it only detects lines beginning with "--", those with preceding whitespace are missed.
I know I could use something like
/^--/||/^ *--/||/^\t*--/
for my pattern, but this still does not pick up the arbitrary mixes of spaces and tabs so beloved of my developer community.
grep -n "^[:space:]*--" FILE does the same.
Ideas anyone ?
Graham
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2001 05:11 AM
09-26-2001 05:11 AM
Re: awk question regarding /[:space:]/ and REs
Try filtering out the whitespace before, as:
cat FILE | sed 's/[ ]*//' | awk ' /--/ {printf "%6d: %s\n", NR, $0}'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2001 05:14 AM
09-26-2001 05:14 AM
Re: awk question regarding /[:space:]/ and REs
I should add, perhaps obviously (?) that inside the "[ ]" expression to 'sed' is a 'space' and a 'tab' character. That is, type '[', 'space', 'tab', ']'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2001 05:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2001 05:36 AM
09-26-2001 05:36 AM
Re: awk question regarding /[:space:]/ and REs
character classes require *double* square brackets, e.g.
cat /tmp/file |awk ' /^[[:space:]]*--/ {printf "%6d: %s\n", NR, $0}'
1: -- abc
2: -- def
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2001 05:37 AM
09-26-2001 05:37 AM
Re: awk question regarding /[:space:]/ and REs
Brilliant !
Thanks.