[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sort file without sort first line or first two lines ?
From: |
Barry Margolin |
Subject: |
Re: sort file without sort first line or first two lines ? |
Date: |
Fri, 21 Jan 2011 09:00:48 -0500 |
User-agent: |
MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) |
In article
<fda30a91-58d9-4a6c-9b1d-b229c8a66381@t35g2000yqj.googlegroups.com>,
moonhkt <moonhkt@gmail.com> 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
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***