sort Linux Commands

What is Linux sort Command?

Explanation

sort COMMAND:

sort command is used to sort the lines in a text file.

SYNTAX :


sort [options] filename

OPTIONS:


-r Sorts in reverse order.
-u If line is duplicated display only once.
-o filename Sends sorted output to a file.

EXAMPLE:


  1. sort test.txt

    Sorts the 'test.txt'file and prints result in the screen.
  2. sort -r test.txt

    Sorts the 'test.txt' file in reverse order and prints result in the screen.

Ask Questions

Ask Question