[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sort -g (generic numeric) is working only for the first key
From: |
Wasim Akram S.N. |
Subject: |
Re: sort -g (generic numeric) is working only for the first key |
Date: |
Sat, 07 Mar 2009 09:01:43 +0530 |
User-agent: |
Thunderbird 2.0.0.19 (X11/20090105) |
Hi Anreas / Eric,
> Erik Auerswald <address@hidden> writes:
>
>
>> Hi Wasim,
>>
>> On Sun, Mar 01, 2009 at 08:09:43PM +0530, Wasim Akram S.N. wrote:
>>
>>> Hi,
>>> I don't know whether the following is really a bug.
>>> ...
>>> address@hidden:~/temp$ sort -g -k1,3 -t \t a
>>>
>> This tells sort to regard the first three fields as one key. I think
>> you need something like "sort -g -k1,1 -k2,2 -k3,3 -t \t a" which uses
>> the three fields as three keys.
>>
>
> This won't work either since the separator 't' does not occur in the
> input. If you want a TAB character as a separator (assuming there are
> really TABs between the fields in the input) you need to pass a literal
> TAB as the argument to -t. With bash you can do that with -t $'\t'.
>
> Andreas.
>
>
Based on your suggestion, I tried this and now its working.
address@hidden:~/temp$ sort -g -k1,1 -k2,2 -k3,3 -k4,4 -t $'\t' a
1 1 1
2 2 2
4 1 1
4 2 2
4 10 10
4 100 100
10 10 10
100 10 1
200 1 1000
200 2 10
200 20 100
address@hidden:~/temp$
Thanks a ton
Regards,
Wasim Akram