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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need to fields from different lines

Status
Not open for further replies.

chaosranger

Technical User
Nov 12, 2002
1
AT
Hi

I am a awk newbie and i need your help.

I have following data:

02 A2 14334 2155 15.0 NW 38476 5804
34242 3424 14.0 SW 34434 3434

I need to fields $1 from 1.line and $4 from 2.line to compare and to print the $3 from 2.line

awk '$1 == 01 && $4 == "SW" { print $3}' data
(this don't works)

How can i do this?

THX
 
Something like this...

awk ' {
if (NR == 1 && $1 == "01") {
a = 1
}
if (NR == 2 && $4 == "SW" && a > 0) {
print $3
}
}'

 
....and zeroise 'a' after 'print $3' ???????? Dickie Bird
Honi soit qui mal y pense
 
Yeah, I'm missing something here..
I was under the impression he was stumped on
how to use NR and had two lines to worry about..

If there is more to it, then I, at least, need
to see a better data sample..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top