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

Compare and delete certain lines 1

Status
Not open for further replies.

rkdash

Technical User
Jul 15, 2004
14
US
Hi all,

I have two files that look like:

File 1:

20.076 -0.200 2.858
20.477 -0.200 2.869
20.878 -0.200 2.880
21.280 -0.200 2.890
21.681 -0.200 2.894
22.082 -0.200 2.892

File 2:
20.076 -0.200 0.000
20.477 -0.200 0.000
20.878 -0.200 0.000
21.280 -0.200 0.001
21.681 -0.200 0.015
22.082 -0.200 0.020

The first two columnsof the files are same. I want to compare the 3rd column of these two files and retain only those lines of File 1 for which 3rd column of File 2 has non-zero values. So, my File-3 should look like

File 3:

21.280 -0.200 2.890
21.681 -0.200 2.894
22.082 -0.200 2.892

Thanks in advance,

rkd
 
A starting point:
nawk 'NR==FNR{a[NR]=$3;next}a[FNR]' File2 File1 > File3

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

Part and Inventory Search

Sponsor

Back
Top