COMM and Numerical Sorting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting COMM and Numerical Sorting
# 1  
Old 02-26-2010
COMM and Numerical Sorting

Hi,

Hope someone can shed some light on this...
I have two lists of numbers I am comparing using COMM. If the first list is empty, and I sort both lists like so:
Code:
DIFF=`comm -3 <(echo "$EMPTY" | sort -n) <(echo "$NUMBERS" | sort -n)`

I get the error: comm: file 2 is not in sorted order

But if I drop the numerical sorting from sort:
Code:
DIFF=`comm -3 <(echo "$EMPTY" | sort) <(echo "$NUMBERS" |  sort)`

It works OK. Is there a bug or am I doing something wrong? I have dropped '-n', but I was just wondering if there is a good explanation for this.

Thanks.
Stephen
# 2  
Old 02-26-2010
Question

What is $EMPTY and $NUMBERS?
Do they hold filenames?
# 3  
Old 02-26-2010
Variables containing the lists. $EMPTY is an empty string.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

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 ... (4 Replies)
Discussion started by: RaviTej
4 Replies

2. Programming

Sorting a vector of strings into numerical order.

I have a vector of strings that contain a list of channels like this: 101,99,22HD,432,300HD I have tried using the sort routine like this: sort(mychans.begin(),mychans.end()); For some reason my channels are not being sorted at all. I was hoping someone might have some input that might... (2 Replies)
Discussion started by: sepoto
2 Replies

3. UNIX for Dummies Questions & Answers

help on COMM command please

could some one please explain with examples how comm -12 & comm -3 works. I am confused with manual page, Thankyou. (2 Replies)
Discussion started by: Ariean
2 Replies

4. Shell Programming and Scripting

problem with using comm

hi, I have two unsorted files and want to delete the lines which are common to both. file 1: S1069656304010437 S1069656304010449 S1470204501005393 S1069656304010474 S0001209208001294 S0000000012345678 S0001457507000590 S0002641707000784 S1470204501005381 S0001457507000280... (4 Replies)
Discussion started by: jathin12
4 Replies

5. Shell Programming and Scripting

comm not working

Hi Sorry if this a repeat question, I have the following two files. Both are sorted. file1 ---- CSCeb69473 CSCsg70355 CSCsj78917 CSCsj85065 CSCsl48743 CSCsl72823 CSCsl77748 file2 ---- CSCsg39295 (7 Replies)
Discussion started by: amitrajvarma
7 Replies

6. Shell Programming and Scripting

comm command

Hi I have issue with "comm " command file-1 ---- l65059 l65407 l68607 l68810 l69143 l71310 l72918 l73146 l73273 l76411 file-2 ----- (8 Replies)
Discussion started by: amitrajvarma
8 Replies

7. UNIX for Advanced & Expert Users

comm command in sorting IP

i have 2 files that contains a sorted list of IP addresses. file_A contains a list of all IPs file_B contains only around 50% of what is in file_A. I tried to execute comm -23 file_A file_B > file_C to get the difference. My objective is to put all the IPs that are in file_A but not... (1 Reply)
Discussion started by: tads98
1 Replies

8. UNIX for Dummies Questions & Answers

Comm, command help

See my other post on sdiff .... I don't think sdiff is able to do what I want. The 'comm' command does what I need and works fine as far as the logic and results. The problem I'm having is with the output format, it outputs 3 columns of data, but because of the way it starts each line... (2 Replies)
Discussion started by: cowpoke
2 Replies

9. Shell Programming and Scripting

comm with a variable

Hello all, I have two flat files that are colon delineated and I am trying to run a compare (Solaris v8 ksh) of $1 within a script to access a mysql database based on the results. Unix is telling me that it has to have physical file names. Is there a way to run a compare using variables? This is... (3 Replies)
Discussion started by: gozer13
3 Replies

10. Shell Programming and Scripting

comm ?!

Hi, I have two large files with uid's: - 581004 File1.txt - 292675 File2.txt I want to know which uid's are in File1.txt and not in File2.txt. I have used comm -23 File1.txt File2.txt. This should do the trick i thought. But in the output i keep having uid's in File1.txt that are also in... (8 Replies)
Discussion started by: tine
8 Replies
Login or Register to Ask a Question