sort is a Unix command to order data in file(s) in a sequence.

Syntax

Parameters

Remarks

Full user manual of sort is online

Sort command output

sort command is used to sort a list of lines.

Input from a file

sort file.txt

Input from a command

You can sort any output command. In the example a list of file following a pattern.

find * -name pattern | sort

Make output unique

If each lines of the output need to be unique, add -u option.

To display owner of files in folder

ls -l | awk '{print $3}' | sort -u

Numeric sort

Suppose we have this file: