- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to get next line of grep-matched line
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
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
11-03-2011 01:08 AM
11-03-2011 01:08 AM
How to get next line of grep-matched line
Hi,
Does anyone know how to display next line of grep-matched line?
grep command does not have -A parameter???
I need cluster package name and status, but don't know its name, status, node...
So, I want to get 2 lines from output of following cmviewcl -v .
PACKAGE STATUS STATE AUTO_RUN NODE <--this line and
mypackage up running enabled mynode <--this line
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2011 01:49 AM - edited 11-03-2011 01:53 AM
11-03-2011 01:49 AM - edited 11-03-2011 01:53 AM
Re: How to get next line of grep-matched line
gnu grep has a -A1 option to get the next line.
Or you can use sed or awk to find then print the next line.
awk '
/PACKAGE/ {
print $0
getline
print $0
}' file
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2011 08:31 AM
11-03-2011 08:31 AM
Re: How to get next line of grep-matched line
Yes, GNU grep has the -A option, but HP-UX standard grep does not have it.
Which version of Serviceguard are you talking about?
At least on Serviceguard A.11.17 and newer, you can get the output in a different, machine-parseable format:
cmviewcl -f line -v
This output format might be easier to use in your own scripts.
- Tags:
- cmviewcl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2011 10:41 AM
11-03-2011 10:41 AM
Re: How to get next line of grep-matched line
> Yes, GNU grep has the -A option, but HP-UX standard grep does not have it.
Yes, HP-UX standard grep does not have it, but GNU grep is available for HP-UX.