Skip to content
Advertisement

Reverse sort 3rd numeric column in file

In bash shell scripting, I have users.txt file.

sort -t: -k 3n users.txt gives me

JavaScript

This is ok. But I need 3rd column which contain only phone number in reverse order i.e. descending order. How to achieve that?

I need like

JavaScript

Advertisement

Answer

You could add an r (short for “reverse”) to the order column specification:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement