[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "sort -nu" treatment of "0" & empty lines
From: |
Jim Meyering |
Subject: |
Re: "sort -nu" treatment of "0" & empty lines |
Date: |
Fri, 07 Jan 2005 19:25:33 +0100 |
"Ulrich Hermisson" <address@hidden> wrote:
> Hello,
>
> the following behaviour of "sort -nu" needs not necessarily be considered a
> bug:
>
> $ echo ",2,0,1,-2,3,-4" | tr "," "\n" | sort -nu
> -4
> -2
>
> 1
> 2
> 3
Thanks for the report.
POSIX requires sort, with -n or `-kM,Nn', to interpret an empty field as 0.
The documentation (info sort) already says that an empty field is valid
but doesn't specify how it's interpreted.
I've just added a sentence saying that.
Here's the new description:
`--numeric-sort'
Sort numerically: the number begins each line; specifically, it
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. A
string of zero digits is interpreted as `0'. The `LC_NUMERIC'
locale specifies the decimal-point character and thousands
separator.