[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: different behavior of sort
From: |
Sheila Yao |
Subject: |
RE: different behavior of sort |
Date: |
Tue, 19 Jan 2010 11:50:07 -0500 |
Eric:
So it is not a bug? When I use sort -n -k2.1,2.19, it sorts accordingly.
Thanks.
Have a nice day,
Sheila Yao
-----Original Message-----
From: Andreas Schwab [mailto:address@hidden
Sent: Tuesday, January 19, 2010 11:23 AM
To: Sheila Yao
Cc: Eric Blake; address@hidden
Subject: Re: different behavior of sort
Sheila Yao <address@hidden> writes:
> sort -n -k2.1,2.4 /tmp/sort.out
> /dev/emcpowera 47G 39G 7.8G 84% /DB1/DW/data9
^^^^
The sort key is probably not what you think it is. I have marked it
for you. Since the sort key is identical in all lines, sort has used
as a last resort the whole line as the sort key.
>From sort --help:
POS is F[.C][OPTS], where F is the field number and C the character position
in the field; both are origin 1. If neither -t nor -b is in effect,
characters
in a field are counted from the beginning of the preceding whitespace.
You should probably just use the whole second field as the sort key.
Andreas.
--
Andreas Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."