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 line below and line above

Status
Not open for further replies.

ng1

Technical User
Aug 22, 2007
39
0
0
US
I have an awk script that is getting me part of what I need. It is giving me the lines with the criteria I have specified.

{
if (($3 == 0) || (($9 == 304) || ($9 == 306)))
{ print $0 }
}

Here is what else I need to do but don't know how. In the
(($3==0) part, I ALSO need the line ABOVE that line. In the (($9 == 304) || ($9 == 306))) part, I ALSO need the line BELOW that line.
 
$3==0 {print above}
$3==0 || $9==304 || $9==306
$9==304 || $9==306 {getline;print}
{above=$0}

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for your help. How would I put either of your scripts into a file that I can reference with awk -f ?
 
What I've posted is the content of an awk program file, so I quite don't understand your question.
 
I got it now. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top