- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script Help ?
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
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
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-15-2009 02:38 PM
тАО07-15-2009 02:38 PM
I created a log search script which ssh's to other host log files and finds out errors. Here is a snippet where it cannot find the errors -
#./logsearch.sh
================= cluster 1 host1 ===============
================= cluster 1 host2 =================
================= cluster 2 host3 =================
================= cluster 2 host4 =================
Here is a snippet of where it does find errors -
================= cluster 1 host1 =================
================= cluster 1 host2 =================
specific-errors
specific-errors
....
================= cluster 2 host3 =================
================= cluster 2 host4 =================
I want to create a script which identifies which cluster-host combination has those specific error and then page out to the team with that information specifying cluster-host(which has the errors) in that page.
How do I parse the cluster-host combination which has issues from this output is my question through bash.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-15-2009 03:15 PM
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-15-2009 03:56 PM
тАО07-15-2009 03:56 PM
Re: Script Help ?
This variation yields cleaner output:
# awk '/^===/ {PREV=$0};{if (/error/) {if (PREV) {print PREV;PREV="";print} else {print}}}' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-15-2009 04:25 PM
тАО07-15-2009 04:25 PM
Re: Script Help ?
The following actually worked for me -
awk '/^===/ {PREV=$0};{if (/error/) {print PREV}}' log
If you can explain a little more abt it as well that will be great.
Allan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-15-2009 04:57 PM
тАО07-15-2009 04:57 PM
Re: Script Help ?
> # awk '/^===/ {PREV=$0};{if (/error/) {print PREV;print}}'
> If you can explain a little more abt it as well that will be great.
As each line from your file is read, a test is made to see if the line begins (^) with the characters '==='. If if does, the statement in braces is executed. That is, the whole line ($0) is captured in the 'PREV' variable. A test is then made for lines with the sequence of 'error'. If that test is true, then the 'PREV' variable contents is printed followed by the line just read. In 'awk', a 'print' without any object is a print of the current line (which can also be explicitly written as '$0').
Regards!
...JRF...