bug-coreutils
[Top][All Lists]
Advanced

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

Re: problem with command sort after uniq -c


From: Andreas Schwab
Subject: Re: problem with command sort after uniq -c
Date: Mon, 10 Mar 2008 19:54:04 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (gnu/linux)

Damien ANCELIN <address@hidden> writes:

> 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

This is a useless use of cat, you can just redirect sort's standard
input from the file.

>   1320 51970
>   1692 12345
>  22681 8060
>  26063 8649
>   2668 33603
>   3487 44496
>   4350 23246
>  47013 8000
>   5447 20000
>  81724 5000

I assume that you use the fr_FR locale.  In this locale a number can be
grouped with a space, thus it is considered part of the number.  If you
want to be sure that sort only considers the first field as sort key you
should use -k1,1 to limit it.  The default is to always use the the
whole line as sort key, and sort -n will take as much as possible from
the key to match a number.

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

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