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!

Comparison

Status
Not open for further replies.

stu78

Programmer
May 29, 2002
121
GB
Hi,

How could I do a comparisoin between 2 files, and remove the data which is in file1 from file2?

Is this possible?
 
Check out the diff command

-------------------------
The trouble with doing something right the first time is that noboby appreciates how difficult it was.
- Steven Wright
 
man comm

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
If the files aint 1:1 line-mapped, comm is not much of use.
Some awk:
Code:
{ if (NR == FNR) Seen[$0]; else if (! ($0 in Seen)) print }

. Mac for productivity
.. Linux for developement
... Windows for solitaire
 
Here's another way of implementing xmb's algorithm:
Code:
NR==FNR { a[$0]; next }
!($0 in a)
Run it with
[tt]awk -f comp.awk file1 file2[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top