Need help with comm command

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

cat a.csv | sort > a.csv
cat b.csv | sort > b.csv
comm -23 a.csv b.csv > c.csv.
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  
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)

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

but I am getting

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

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

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 :frowning:

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

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 .