-1
TGAAACATGCCTTTCACCTCCTGCCATGATTGTGAGGCCT 2
GTGTTGCCCAGGTTGGTTTCAAACTCAGCTCAAGTGATCT 1
GAGACTCCTTCAGGAGACTGGTCCCCTGTCCTCGCCTCTC 3
CATGTTCTCCTGGAAGCCATGTGAGGAAGGCACATCATGG 8
AAGGACATAATCTCATTACTTTTATGGCCGCATAGTATTC 4
AGAGGCAGTGTAAGTGAGGTAGTTGAAAGTATGGACTCTG 2

I want to use second column to re-arrange the lines from highest number to lowest

Expected output

CATGTTCTCCTGGAAGCCATGTGAGGAAGGCACATCATGG 8
AAGGACATAATCTCATTACTTTTATGGCCGCATAGTATTC 4
GAGACTCCTTCAGGAGACTGGTCCCCTGTCCTCGCCTCTC 3
AGAGGCAGTGTAAGTGAGGTAGTTGAAAGTATGGACTCTG 2
TGAAACATGCCTTTCACCTCCTGCCATGATTGTGAGGCCT 2
GTGTTGCCCAGGTTGGTTTCAAACTCAGCTCAAGTGATCT 1
  • Welcome to U&L. You're getting downvoted because your question lacks own research. For your next question, make sure to include what you've tried and where you're stuck. If you had done that, I'm sure you would have found an answer on this site. Also, you should explain inside your question why you added 4 different language tags. – pLumo Apr 15 at 15:11
1

Use sort with -k switch:

sort -k2 -nr file
  • -k2 sort field.
  • -n numeric sort (not needed here, as in the example numeric and alphabetic would be the same).
  • -r reverse sorting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.