x

SORT command in Unix

PREV     NEXT

SORT command in Unix:


The sort command in UNIX  is used to arrange the lines of text alphabetically. It will just sort the text alphabetically and displays in the command line. The content of the file will not be modified.

Example for SORT command in Unix:

filename file.txt

Sort file.txt :

returns the following results:

There are many options in sort command. Below are the details,

Sort -n :-

  • This will sort numerically and it will ignore blanks and tabs. If the file contains text as well as numeric lines, then it will first sort alphabets and then it will sort numeric line from low value to high value.

Sort -r :-

  • It will sort the text from the files in reverse order.

Sort -f :-

  • This will sort upper and lowercase texts together.


Like it? Please Spread the word!