Sorting the file or string input in Linux

You can use sort command to sort the contents of a file or input string.

Sorting in acending order

For example – to sort the lines  in a myfile in ascending order, you can use below command.

sort myfile

Sorting in descending order

To sort the lines  in a myfile in descending order, you can use below command.

sort -r myfile

Sorting based on nth column

Sorting numerically

You may also like...