Operating System - HP-UX
1834139 Members
2727 Online
110064 Solutions
New Discussion

Question on the comm-command

 

Question on the comm-command

Hello.

I have a question om the comm-command that is used to "select or reject lines common to two sorted files".

I have two sorted files, called test1 and test2. They look like this :

ELR1:more test1
261
450
790
1006
1261
11261

ELR1:more test2
261
1261

If i want the lines that appear in test1 but not in test2, then :

ELR1:comm -23 test1 test2
450
790
1006
1261
11261

* 1261 should not appear in the result !*

Print all the lines common to test1 and test2 :

ELR1:comm -12 test1 test2
261

* Wait...where is 1261 ? *

Strange....what could be wrong ?
Or am i thinking wrong (i'm tired and it's monday...) ?
3 REPLIES 3
Arunvijai_4
Honored Contributor

Re: Question on the comm-command

Hello,

Is it not #comm -13 a1 a2 ??

Take a look at the man page of "comm". It says,

Column 1: Lines that appear only in file1,
Column 2: Lines that appear only in file2,
Column 3: Lines that appear in both files.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"

Re: Question on the comm-command

ELR1:comm -13 test1 test2
1261

This is not correct either. This should not give any result since both values in file2 are in file1.

Re: Question on the comm-command

It worked when i ran the sort-command on the files before i ran the comm-command.