On Thu, Jan 08, 2009 at 01:20:42PM +0000, George B. wrote:
-n, --numeric-sort
             compare according to string numerical value

The info docs are perhaps more illuminating:

`-n'
`--numeric-sort'
    Sort numerically.  The number begins each line and consists of
    optional blanks, an optional `-' sign, and zero or more digits
    possibly separated by thousands separators, optionally followed by
    a decimal-point character and zero or more digits.  An empty
    number is treated as `0'.  The `LC_NUMERIC' locale specifies the
    decimal-point character and thousands separator.  By default a
    blank is a space or a tab, but the `LC_CTYPE' locale can change
    this.

The key thing is that the number has to be at the beginning (it doesn't try to skip over non-numeric content to find a number).

If you have freedom to create the names you can specify something like word-number, which makes the sorting much easier:

sort -t - -k 1,1 -k 2,2n

The info page ("info coreutils sort") also has a number of examples.

[rant]The last block about POS makes my head hurt. I love Linux, but
why does it have to be so difficult to do something as simple getting
a numerically sorted list of files?[/rant] :-(

Well, if it's just a list of files you can do this:

ls -v

Mike Stone



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to