Difficulty in understanding sort command

Hi,

I have used the following command to get result using some program and got desired output but I am unable to understand the last part: sort -k5,5 -rn|head -n 10

grep Centre groups.dat |sort -k5,5 -rn|head -n 10

Please guide.

Thanks

-k 5,5 means sort on the 5th column. Which column to start on, and which column to end on.
-r means sort in descending order.
-n means sort numerically. (1 2 3 4 5 6 7 8 9 10 11, vs 1 10 11 2 3 4 5 ... )

| head -n 10 means 'only show the first 10 lines'.

2 Likes

Thanks Corona688. :slight_smile: