comm command

Hi

I have issue with "comm " command

file-1
----
l65059
l65407
l68607
l68810
l69143
l71310
l72918
l73146
l73273
l76411

file-2
-----
k55080
g43140
sg55591
j20766
j32013
k28117
k40986
k47893
k98497
l26497
l47365
l76411

when I execute

comm -23 file-2.txt file-1.txt,

It should showing l76411 , why is it happening, because it should show only list which is not present in file-1.

Please let me know

Thx

Arv

comm works on sorted files

Is file2 sorted ?

Hi madhan,

I have given extract of file1 and file2. Both are sorted,
when I execute it "comm -23 file-2.txt file-1.txt"..it is still showing "l76411". Ideally it should not right..bcos it is available in both files.

Any idea why so?

Thanks

Amit

comm -23 'll print only the line which is there in the first file. ( should not present in the second )

l76411 is present in both the file therefore its not there in the o/p.

the o/p is currect. infact u are expecting a wrong o/p from the UNIX.

remember when u give comm -23 file2.txt file1.txt

file2.txt 'll be treated as file1 ( the first arg )of the comm std i/p. and file1.txt as the seconds arg.

Anchal

Hi Anchal,

I want to see the only contents in file2 which are not there in file1. How do I achieve that with comm

Thx

Amit

comm fork on sorted files :

cat file1 | sort > file11
cat file2 | sort > file22
comm -23 file22 file11
g43140
j20766
j32013
k28117
k40986
k47893
k55080
k98497
l26497
l47365
sg55591

:slight_smile:

Not good :confused: :frowning:

Hi, V3,
Thanks, If the file1 is very large will comm work. In that case what could be the alternativ?
Thx
Amit

When a file is too big, you have the "split" command. Good luck ! :cool: