gnu-misc-discuss
[Top][All Lists]
Advanced

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

Re: sort file without sort first line or first two lines ?


From: David Kastrup
Subject: Re: sort file without sort first line or first two lines ?
Date: Tue, 25 Jan 2011 10:18:11 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

David Kastrup <address@hidden> writes:

> moonhkt <address@hidden> writes:
>
>> On Jan 21, 10:00 pm, Barry Margolin <address@hidden> wrote:
>>> In article
>>> <address@hidden>,
>>>
>>>
>>>
>>>  moonhkt <address@hidden> wrote:
>>> > How to sort file without sort first line or first two lines ?
>>>
>>> > Text file as below
>>> > MTH    NUM
>>> > JAN    A      1
>>> > APR    C
>>> > FEB    B      1
>>> > MAR    D      1
>>>
>>> > Expect Output
>>> > MTH    NUM
>>> > JAN    A      1
>>> > FEB    B      1
>>> > APR    C
>>> > MAR    D      1
>>>
>>> { head -1 file; tail -2 file | sort +k 2; } > sortedfile
>>>
>>
>> Tried, Not worked.
>
> You'll need  tail -n +2 file  here.

Or do something like

cat file | { IFS="" read -r x; echo "$x"; sort +k 2; } >sortedfile


-- 
David Kastrup


reply via email to

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