bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: comm command bug while using with Tilda delimited files


From: Anand Ramamoorthy
Subject: RE: comm command bug while using with Tilda delimited files
Date: Fri, 26 May 2006 08:35:02 +1000

Thanks Brian for a quick response. Infact I do sort the file prior to 
processing it. But I use the following:
 
sort -t"~" -k1,1 file1 -o file1
 
And I get the output mentioned below since 5 comes before 55. I'm purposely not 
using Numeric sort as I'm writing a generic script and my primary fields can be 
non-numeric fields as well.
 
Looks like I will have to settle for a normal sort rather than key based sort 
for this to work.
 
Thanks,
Anand

________________________________

From: Brian Dessent [mailto:address@hidden
Sent: Thu 25/05/2006 11:51 PM
To: Anand Ramamoorthy
Cc: address@hidden
Subject: Re: comm command bug while using with Tilda delimited files



Anand Ramamoorthy wrote:

> This is the first time I'm having issues with "comm" command on an HP-UX Unix 
> box (Model: 9000/800, Release: B11.11)
>
> I'm trying to compare two files that are "~" delimited.
>
> File 1
> --------
> 1~10
> 5~30
> 55~40
> 6~20
>
>
> File 2
> --------
> 1~20
> 5~35
> 55~40
> 7~27

'comm' requires that the input files be sorted.  These are not sorted,
because "~" comes after "5" in the ascii order.  You can test this for
yourself with something like:

$ echo -e "5~30\n55~40" | sort
55~40
5~30

It works when you use "," because that character comes before the digits
in the ascii order.  Run your input files through 'sort' before passing
them to 'comm'.

Brian



IMPORTANT
1.      This email and any attachments are confidential.  Any unauthorised 
dissemination or other use of these materials is prohibited.  If received in 
error, please contact us and delete all copies.  
2.      Before opening or using attachments, check them for viruses and 
defects.  Our liability is limited to resupplying any affected attachments. 
3.      Protecting your privacy is important to us.  Our privacy statement and 
further information is available at www.oakton.com.au.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]