Re: sort

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

 



Hi,

cat filename; echo -e \n Sorted:- "; cat filename | tail +2 | sort -k2
Shankar RHCE


On 6/20/06, vipin sagar <sagar.vipin@xxxxxxxxx> wrote:

Mr.Sean is correct.

...a litle bit from my side...

[vipin@vipin ~]$ grep -v age testsort.txt | awk '{print $2}' | sort -r


On 6/19/06, Miner, Jonathan W (CSC) (US SSA)
<jonathan.w.miner@xxxxxxxxxxxxxx> wrote:
>
>
>         -----Original Message-----
>         From: redhat-list-bounces@xxxxxxxxxx on behalf of Aimin Yan
>         Sent: Sat 06/17/2006 02:23 PM
>         To: redhat-list@xxxxxxxxxx
>         Cc:
>         Subject: sort
>
>
>
>         i have a file, I want to sort this file based on the 2nd column,
and start
>         from 1st row.how can
>         I do use sort command to do in redhat linux.
>         for example, this is file I want to sort
>
>
>         name  age  income
>         trorry   34    344
>         aimin   36    345
>         shihe   23    3667
>
>         Aimin
>
>         -----------------------------
>
>         Lots of possible answers to this, here is one that preserves the
header line, and the rest of the file contents:
>
>         f={filename}
>
>         (head -1 $f; awk 'BEGIN {getline} {print $0}' $f | sort -k2 -n)
> $f.new
>
>         mv $f.new $f
>
>
>
>         This depends on having a single title line in the field, a
better method, in my opinion, is to use the pound sign (#) to mark
comments.  The code then becomes:
>
>         f={filename}
>
>         (grep '^#' $f; grep -v '^#' $f | sort -k2 -n) > $f.new
>
>         mv $f.new $f
>
>
>
>         Enjoy
>
>
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
>
>


--
~O_0~
~sagar
http://vipinsagar.be
...i've to look back when i heard a gong! i could only see a huge
cobweb and its shining, just got wonder, what the time it was…5AgAr

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subjecthttps://www.redhat.com/mailman/listinfo/redhat-list


[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux