Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-09-2012
Registered User
 
Join Date: Jun 2012
Posts: 14
Thanks: 5
Thanked 1 Time in 1 Post
Need help with comm command

Hello , I am trying to get contents which are only present in a.csv ,so using comm -23


Code:
cat a.csv | sort > a.csv
cat b.csv | sort > b.csv
comm -23 a.csv b.csv > c.csv.


Code:
a.csv
SKU     COUNTRY     CURRENCY     PRICE_LIST_TYPE     LIST_PRICE_EFFECTIVE_DATE
TG430ZA    ZA    USD    DF    2012-03-28    9999-12-31    120000    
TG431ZA    ZA    USD    DF    2012-03-28    9999-12-31    96000    
TG432ZA    ZA    USD    DF    2012-03-28    9999-12-31    1200    
TG433ZA    ZA    USD    DF    2012-03-28    9999-12-31    12000


Code:
b.csv 
SKU     COUNTRY     CURRENCY     PRICE_LIST_TYPE     LIST_PRICE_EFFECTIVE_DATE  
TG431ZA    ZA    USD    DF    2012-03-28    9999-12-31    96000    
TG432ZA    ZA    USD    DF    2012-03-28    9999-12-31    1200    
TG433ZA    ZA    USD    DF    2012-03-28    9999-12-31    12000

When I run the script , expected result is (2nd line of a.csv TG430ZA is not present in b.csv)

Code:
TG430ZA    ZA    USD    DF    2012-03-28    9999-12-31    120000

but I am getting

Code:
SKU     COUNTRY     CURRENCY     PRICE_LIST_TYPE     LIST_PRICE_EFFECTIVE_DATE
TG430ZA    ZA    USD    DF    2012-03-28    9999-12-31    120000

Can any help me on this please. I have tried using comm -2 -3 also ..its same

Last edited by methyl; 07-10-2012 at 06:38 AM.. Reason: Please use code tags.
Sponsored Links
    #2  
Old 07-09-2012
alister alister is offline Forum Advisor  
Registered User
 
Join Date: Dec 2009
Posts: 2,601
Thanks: 123
Thanked 717 Times in 600 Posts
There's probably some difference between the headers. Perhaps a carriage return, or an extra space or tab somewhere? Take a close look with od, hd, hexdump, or sed -n l.

Regards,
Alister
Sponsored Links
    #3  
Old 07-09-2012
Registered User
 
Join Date: Jun 2012
Posts: 14
Thanks: 5
Thanked 1 Time in 1 Post
I copied exact same line from a.csv into b.csv
SKU COUNTRY CURRENCY PRICE_LIST_TYPE LIST_PRICE_EFFECTIVE_DATE

without any spacing errors , but output is same ... I do not understand why comm is unable to comprehend this line . Have been on this issue for a lot of time
    #4  
Old 07-09-2012
alister alister is offline Forum Advisor  
Registered User
 
Join Date: Dec 2009
Posts: 2,601
Thanks: 123
Thanked 717 Times in 600 Posts
Did you take a look at it with one of the tools I suggested? If not, do so. If you do not know how to interpret their output, post it here (and make sure to use code tags to preserve the formatting).

Regards,
Alister
The Following User Says Thank You to alister For This Useful Post:
RaviTej (07-09-2012)
Sponsored Links
    #5  
Old 07-09-2012
Registered User
 
Join Date: Jun 2012
Posts: 14
Thanks: 5
Thanked 1 Time in 1 Post
Hello alister ,

Thank you . I got the mistake , there is a blank space appended at the end of first line . Thanks a lot for the help .
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 06:52 PM
help on COMM command please Ariean UNIX for Dummies Questions & Answers 2 07-08-2010 01:05 PM
help in comm command arunkumar_mca UNIX for Dummies Questions & Answers 1 04-27-2009 11:04 AM
comm command amitrajvarma Shell Programming and Scripting 8 02-06-2008 04:20 AM
Comm, command help cowpoke UNIX for Dummies Questions & Answers 2 10-25-2005 08:26 AM



All times are GMT -4. The time now is 02:37 AM.