Reputation: 1215
I have a list in txt file as below
a 2
b 3
c 1
d 7
e 2
I need to write a script that will arrange the list in descending order of the value as below
d 7
b 3
a 2
e 2
c 1
I tried to sort this, but it sorts alphabetically, but doesn't sort by the second column value.
Could anyone please suggest me how to do this?
Upvotes: 0
Views: 316
Reputation: 1844
sort -k 2r file
-k 2r
to sort in reverse using the second column.
Upvotes: 2