1834711 Members
2564 Online
110069 Solutions
New Discussion

Re: comparing files

 
subhashni
Regular Advisor

comparing files

Hi,
I just need to compare two files and i want output as lines which are not common to both files.I tried diff and comm.I did not get what i want.Any help.?
Thanks
unix4me
3 REPLIES 3
H.Merijn Brand (procura
Honored Contributor

Re: comparing files

comm requires the input files to be sorted

if both files have unique keys, you can start experimenting with 'join'

perl offers several modules that deal with diff formats or do the diff themselves. Text::Diff is the first that comes to mind. enter diff as search criterium on search.cpan.org
Enjoy, Have FUN! H.Merijn
Eric Hess
Advisor

Re: comparing files

Have you tried using comm twice, firstly using comm -23 file1 file2, then using comm -13 file1 file2.

This will take the lines that are only in 1 file, then the lines that are only in the other file. You should use > in the first command to redirect the output into a new file, then >> to append the result of the 2nd file.

Don't forget to use sort first
I didn't do it. He did!
Darren Prior
Honored Contributor

Re: comparing files

Please note the author has submitted this question twice - here's the other thread: http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x7d58b10230dcd61190050090279cd0f9,00.html

regards,

Darren.
Calm down. It's only ones and zeros...