[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
problem with command sort after uniq -c
From: |
Damien ANCELIN |
Subject: |
problem with command sort after uniq -c |
Date: |
Mon, 10 Mar 2008 17:15:03 +0100 |
User-agent: |
Mozilla-Thunderbird 2.0.0.9 (X11/20080110) |
Hello,
I met a problem with the sort command : I've used the uniq command with
the -c option to count some numbers, and then applying sort -n don't
sort lines by numeric order of the first field.
Here is an example (my sort version is 5.97) :
$ cat bug_sort | sort -n
1320 51970
1692 12345
22681 8060
26063 8649
2668 33603
3487 44496
4350 23246
47013 8000
5447 20000
81724 5000
If I add a non-numeric and non-space character between the 2 fields,
sort -n works properly :
$ cat bug_sort | sed "s/\([0-9]\) \([0-9]\)/\1 -\2/" | sort -n
1320 -51970
1692 -12345
2668 -33603
3487 -44496
4350 -23246
5447 -20000
22681 -8060
26063 -8649
47013 -8000
81724 -5000
With only spaces between the 2 fields, sort -n read 1 number per line
and use it to do the sort : 2668 33603 is read as 266833603. With this
consideration, the result of sort is correct, but it's not what I
expected (and I didn't see this behaviour in the documentation).
Regards,
Damien
--
Damien ANCELIN
INRIA - ENS-Lyon, LIP (RESO)
Bureau 322 Sud
Tel : +33 4 72 72 85 02
- problem with command sort after uniq -c,
Damien ANCELIN <=