Shell provides different ways to sort the input text using the
sort command. It's also possible to remove repeated lines from sorted/unsorted input text using the
uniq command. The input text to sort and
uniq commands can be given from a file, or redirected from another command.
The lines in the input text are sorted in the following order:
The syntax will be as follows:
sort [OPTION] [FILE …]
Single or multiple input files can be provided to sort for sorting.
sort command takes multiple options to provide flexibility in sorting. The popular and important
OPTION to sort have been discussed in the following table: