Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Go to solution
Highlighted
Mike_305
Super Advisor

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.
2 REPLIES
Uday_S_Ankolekar
Honored Contributor
Solution

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/m-p/3703431#M249759

 

-USA

Good Luck..
Dennis Handly
Acclaimed Contributor

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".