How to read couple lines before and after in GREP command in HP-UX (1565 Views)
Reply
Super Advisor
Mike_305
Posts: 374
Registered: ‎09-12-2001
Message 1 of 3 (1,565 Views)
Accepted Solution

How to read couple lines before and after in GREP command in HP-UX

Hello,

 

IN HP UX how can I read couple lines before and after in grep command.

 

grep "SAS" syslog.log.

 

Trying to read the lines before and after.

 

Thanks for your help in advance.

 

Regards,

 

MJ

If there is problem then don't think as problem, think as opportunity.
Please use plain text.
Honored Contributor
Uday_S_Ankolekar
Posts: 2,021
Registered: ‎06-05-2001
Message 2 of 3 (1,557 Views)

Re: How to read couple lines before and after in GREP command in HP-UX

Just search this forum and you will find plenty of solutions :-)

 

Here is one

 

http://h30499.www3.hp.com/t5/System-Administration/grep-for-string-but-include-lines-above-and-below...

 

-USA

Good Luck..
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,762
Registered: ‎03-06-2006
Message 3 of 3 (1,551 Views)

Re: How to read couple lines before and after in grep command in HP-UX

If you install GNU grep, there is a -A # and -B # to get a bigger "window".

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation