- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- scripting/awk
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
11-03-2005 08:36 AM
11-03-2005 08:36 AM
awk '/jA3LQqS29893/{print}' /var/mail/fred
What I really want, is to print the first "Subject:" line that follows a match for the message ID. No way to know how many lines between them.
Any suggestions? Please no perl etc. lets stick to awk.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 08:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 09:04 AM
11-03-2005 09:04 AM
Re: scripting/awk
Just noticed though, not all messages have a Subject tag in a mail file. That means there's a possibilty that we hit the end of the file, or the next message '^From ' and we need to terminate, subject or not...
How about that one?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 09:07 AM
11-03-2005 09:07 AM
Re: scripting/awk
get a line
if end of file
or beginning of next message
then terminate, else
if Subject, print line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 09:14 AM
11-03-2005 09:14 AM
Re: scripting/awk
OK, then amend this way, perhaps:
# awk '/jA3LQqS29893/ {do {getline} while ($0!~/^Subject/ && $0!~/^From/);if ($0~/^From/) {exit};print}'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 10:16 AM
11-03-2005 10:16 AM
Re: scripting/awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 12:31 PM
11-03-2005 12:31 PM
Re: scripting/awk
awk '/jA3LQqS29893/ {flag = 1;}
/^Subject/ {if (flag == 1) {print;exit;}}
/^From/ {if (flag == 1) {exit;}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 01:08 PM
11-03-2005 01:08 PM
Re: scripting/awk
You should take time to review awk
pls refer:
http://www.cs.hmc.edu/qref/awk.html
http://www.vectorsite.net/tsawk.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2005 02:30 AM
11-04-2005 02:30 AM