comm command | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

comm command

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-04-2008
amitrajvarma amitrajvarma is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 15 June 2010, 2:31 AM EDT
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #2  
Old 02-04-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
 
Join Date: Mar 2005
Last Activity: 5 July 2014, 11:14 AM EDT
Location: classification algos
Posts: 3,203
Thanks: 19
Thanked 30 Times in 27 Posts
comm works on sorted files

Is file2 sorted ?
Sponsored Links
    #3  
Old 02-04-2008
amitrajvarma amitrajvarma is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 15 June 2010, 2:31 AM EDT
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
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
    #4  
Old 02-05-2008
clx clx is offline Forum Advisor  
Registered User
 
Join Date: Jun 2007
Last Activity: 31 October 2014, 8:56 AM EDT
Location: Mumbai, India
Posts: 1,614
Thanks: 125
Thanked 184 Times in 178 Posts
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
Sponsored Links
    #5  
Old 02-05-2008
amitrajvarma amitrajvarma is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 15 June 2010, 2:31 AM EDT
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #6  
Old 02-05-2008
V3l0 V3l0 is offline
Registered User
 
Join Date: Nov 2007
Last Activity: 10 April 2008, 10:18 AM EDT
Location: Belgium & France
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
comm fork on sorted files :

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

Sponsored Links
    #7  
Old 02-05-2008
V3l0 V3l0 is offline
Registered User
 
Join Date: Nov 2007
Last Activity: 10 April 2008, 10:18 AM EDT
Location: Belgium & France
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Not good
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
HPUX and comm command guessingo Shell Programming and Scripting 3 05-02-2012 07:52 PM
help on COMM command please Ariean UNIX for Dummies Questions & Answers 2 07-08-2010 02:05 PM
help in comm command arunkumar_mca UNIX for Dummies Questions & Answers 1 04-27-2009 12:04 PM
comm command in sorting IP tads98 UNIX for Advanced & Expert Users 1 05-16-2006 08:41 AM
Comm, command help cowpoke UNIX for Dummies Questions & Answers 2 10-25-2005 09:26 AM



All times are GMT -4. The time now is 09:41 PM.