| Author |
duplicate entries - compare files
|
|
| tester 2006-09-28, 1:38 am |
| Hi Gurus,
I need to compare two files which shows me ONLY duplicate entries
(entry common to both files)
i tried "comm" command but it doesn't show me correctly or may be i am
not using it correctly.
Please Help
Regards
| |
| Ed Morton 2006-09-28, 1:38 am |
| tester wrote:
> Hi Gurus,
> I need to compare two files which shows me ONLY duplicate entries
> (entry common to both files)
> i tried "comm" command but it doesn't show me correctly or may be i am
> not using it correctly.
> Please Help
> Regards
>
comm only works on files that are sorted. Sort the files first.
Ed.
| |
| Hubble 2006-09-28, 1:38 am |
| tester wrote:
> Hi Gurus,
> I need to compare two files which shows me ONLY duplicate entries
> (entry common to both files)
> i tried "comm" command but it doesn't show me correctly or may be i am
> not using it correctly.
> Please Help
> Regards
You have to sort the files before using commm. Another simple solution
is to use the -d option of uniq (after sorting, of course):
sort file1 file2 | uniq -d
Hubble.
| |
|
| have you tried diff? sdiff or diff --side-by-side, etc...
no need to reinvent the wheel
tester wrote:
> Hi Gurus,
> I need to compare two files which shows me ONLY duplicate entries
> (entry common to both files)
> i tried "comm" command but it doesn't show me correctly or may be i am
> not using it correctly.
> Please Help
> Regards
| |
| tester 2006-09-28, 7:27 pm |
|
>
> You have to sort the files before using commm. Another simple solution
> is to use the -d option of uniq (after sorting, of course):
>
> sort file1 file2 | uniq -d
>
> Hubble.
Thanks Hubble. it worked....
Regards
|
|
|
|