The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can you limit the compare on "comm" command eja UNIX for Dummies Questions & Answers 0 03-23-2007 08:48 AM
comm command in sorting IP tads98 UNIX for Advanced & Expert Users 1 05-16-2006 04:41 AM
Comm, command help cowpoke UNIX for Dummies Questions & Answers 2 10-25-2005 05:26 AM
comm with a variable gozer13 Shell Programming and Scripting 3 07-13-2005 05:29 PM
comm ?! tine Shell Programming and Scripting 8 12-07-2003 11:52 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-04-2008
Registered User
 

Join Date: Oct 2007
Posts: 43
Stumble this Post!
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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-04-2008
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,572
Stumble this Post!
comm works on sorted files

Is file2 sorted ?
Reply With Quote
  #3 (permalink)  
Old 02-04-2008
Registered User
 

Join Date: Oct 2007
Posts: 43
Stumble this Post!
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
Reply With Quote
  #4 (permalink)  
Old 02-04-2008
Registered User
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 98
Stumble this Post!
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
Reply With Quote
  #5 (permalink)  
Old 02-05-2008
Registered User
 

Join Date: Oct 2007
Posts: 43
Stumble this Post!
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
Reply With Quote
  #6 (permalink)  
Old 02-05-2008
Registered User
 

Join Date: Nov 2007
Location: Belgium & France
Posts: 70
Stumble this Post!
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
Reply With Quote
  #7 (permalink)  
Old 02-05-2008
Registered User
 

Join Date: Nov 2007
Location: Belgium & France
Posts: 70
Stumble this Post!
Not good
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0