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!

two files comparison

Status
Not open for further replies.

agilo

Programmer
Feb 4, 2004
73
TR
Hi,

I have the following two files.

File1:

x1 x2 x3 x4 x5
name1 12 34 43 3
name2 44 34 76 76
name3 21 23 21 23
name4 5 67 76 76

and File2:

x1 x2 x3 x4 x5
name1 12 34 43 3
name3 21 23 21 23
name7 32 43 23 32

I want to write out the missing lines from Files2 (which exist in File1) and the added (new)lines in File2 (which do not exist in File1) into two seperate output files.

Any ideas are welcomed...

Thanks in advance,

Agilo

 
man comm

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PHV,

first thank you for your reply. It seems the comm command can do it. I tried the three options to seperate the added/removed lines from both files into two different files but unfortunately no success. Could you please help.

Thankx in advance

 
Something like this ?
comm -23 file1 file2 > file1only # missing from file2
comm -13 file1 file2 > file2only # new in file2

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
have you considered the unix commands diff or sdiff?
man sdiff

-------------------------
John Herman is available for short and long term data warehousing consulting and contracts.
 
Thanks Guys,
the output of the comm command matches better my requirments.

agilo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top