Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print pervious 10 lines when a pattern match found

Status
Not open for further replies.

netbackup1234

Programmer
Aug 27, 2006
24
US
Hi
I have file like following ..
RSB995 Private
RSB999 Private
RSD013 Private
RSD022 Private
RSD070 Private
RSD083 Private
RSD094 Private
RSD163 Private
SC7387 Private
SC7397 Private
SC8122 Private
SC8175 Private
SC8212 Private
SC8250 Private
SC8251 Private
SC8290 Private
SC8405 Private

When pattern matches SC8290 , print all pervious 10 lines.

How can this be done using awk ?
 
And what have you tried so far ?
Tip: have a look at the modulo operator (NR % 10)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top