- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Please help.. a clever script needed to...
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
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
04-01-2004 09:54 PM
04-01-2004 09:54 PM
Please help.. a clever script needed to...
I have an ASCII file containing hundreds of ITO/OVO Errors, in a format as follows:-
SEVERITY Critical
APPLICATION "MPG"
MSGGRP "OS"
OBJECT "peanut"
TEXT "Big problems with this jobby"
SEVERITY Warning
APPLICATION "MPG"
MSGGRP "OS"
OBJECT "peanut"
TEXT "Warning, some problems in jobby"
SEVERITY Critical
APPLICATION "MPG"
MSGGRP "OS"
OBJECT "peanut"
TEXT "Mad problems with this jobby"
SEVERITY Normal
APPLICATION "MPG"
MSGGRP "OS"
OBJECT "peanut"
TEXT "This job is OK!"
SEVERITY Critical
APPLICATION "MPG"
MSGGRP "OS"
OBJECT "peanut"
TEXT "I'd check this one out"
...and I need to extract all the Critical instances to a seprate ASCII file. For example, I need to capture every instance of "SEVERITY Critical", and the four lines that follow this statement, and place them in a seperate file, and continue the search in the original file for the next instance, so at the end, I will have a file which reads:-
SEVERITY Critical
APPLICATION "MPG"
MSGGRP "OS"
OBJECT "peanut"
TEXT "Big problems with this jobby"
SEVERITY Critical
APPLICATION "MPG"
MSGGRP "OS"
OBJECT "peanut"
TEXT "Mad problems with this jobby"
SEVERITY Critical
APPLICATION "MPG"
MSGGRP "OS"
OBJECT "peanut"
TEXT "I'd check this one out"
...now I beleive a while read statement will acheive this for me, but my Unix scripting not being what it should be.. I turn to you guys for assistance on this. Can anyone provide a script to do this.. or is it actually possible?? (I am sure it must be!)
Many thanks in advace.....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2004 10:01 PM
04-01-2004 10:01 PM
Re: Please help.. a clever script needed to...
cat
/SEVERITY/ && /Critical/ { crit=1 }
crit==1 { print }
/^$/ { crit=0 }'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2004 10:02 PM
04-01-2004 10:02 PM
Re: Please help.. a clever script needed to...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2004 10:05 PM
04-01-2004 10:05 PM
Re: Please help.. a clever script needed to...
awk '/SEVERITY Critical/,/^\n/{print $0}' file.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2004 10:06 PM
04-01-2004 10:06 PM
Re: Please help.. a clever script needed to...
You can get GNU grep at HP porting centre.
This came up few times in the week. Search the forums.
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2004 10:10 PM
04-01-2004 10:10 PM
Re: Please help.. a clever script needed to...
cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2004 10:17 PM
04-01-2004 10:17 PM
Re: Please help.. a clever script needed to...
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2004 10:32 PM
04-01-2004 10:32 PM
Re: Please help.. a clever script needed to...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2004 10:32 PM
04-01-2004 10:32 PM
Re: Please help.. a clever script needed to...
awk '{
if(substr($0,1,17)=="SEVERITY Critical") {
for(i=0; i < 5;i++) {print $0; getline;}
}
}'
Regards,
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2004 10:52 PM
04-01-2004 10:52 PM
Re: Please help.. a clever script needed to...
not
awk '/SEVERITY Critical/,/^\n/{print $0}' file.txt
only
awk '/SEVERITY Critical/,/^$/{print $0}' file.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2004 12:26 AM
04-02-2004 12:26 AM
Re: Please help.. a clever script needed to...
However.. the file is not as clean as I have made it appear above. It also has a lot of unwanted Junk in there, but I am only interested in the messages which appear above out of it. They are all indented in the file, eg:-
blah, blah, blah, blah........
SEVERITY Critical (Needed)
Line 1 (Needed)
Line 2 (Needed)
Line 3 (Needed)
Line 4 (Needed)
blah, blah, blah, blah,
blah, blah, blah, blah
.. u get this idea.. so I am sorry for not clarifying this initially! If anyone wants me to send them the file (4mb) or attach it here (Can I do that with 4mb!?) I will do so...
Many thanks again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2004 02:20 AM
04-02-2004 02:20 AM
Re: Please help.. a clever script needed to...
Take Elmar's solution, and modify it:
awk '
/SEVERITY/ && /Critical/ { crit=1 }
/SEVERITY/ && !/Critical/ { crit=0 }
crit==1 { print }
'