Question about sort specific column and print other column at the same time !

Hi,

This is my input file:

ali 5 usa abc
abu 4 uk bca
alan 6 brazil bac
pinky 10 utah sdc

My desired output:

pinky 10 utah sdc
alan 6 brazil bac
ali 5 usa abc
abu 4 uk bca

Based on the column two, I want to do the descending order and print out other related column at the same time.
Does anybody know how to do it?
I'm not sure whether awk can do this or not?
Thanks for all of your suggestion:)

sort -nrk2 file

See man sort

---------- Post updated at 06:29 AM ---------- Previous update was at 06:28 AM ----------

To keep the forums high quality for all users, please take the time to format your posts correctly.

  1. Use Code Tags when you post any code or data samples so others can easily read your code.
    You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags and by hand.)
  2. Avoid adding color or different fonts and font size to your posts.
    Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.
  3. Be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
Reply With Quote

Hi Danmero,

Thanks for your reply.
It is worked d.
I will keep it mind about your suggestion to maintain the forum at high quality :slight_smile:

Just edit your previous post(s) and add [code] tags.