Sort or merge lines from a file, and write to standard output.


sort [options] [files]


-c checks if files are already sorted and prints error message if not.

-m merges files by sorting them as a group.

-b ignores leading blanks.

-d sorts in phone directory order (using only letters, digits, and blanks).

-f treats lowercase letters as equivalent to uppercase letters.

-k pos1[,pos2] specifies the sort field as characters between the two positions pos1 and pos2.

-o file writes output to the specified file instead of standard output.

-r sorts in reverse order.

-g sorts numerically after converting the prefix of each line into a floating-point number.

-i ignores unprintable characters.

-n sorts numerically (used when a number begins each line).

-tc specifies the separator character.

+n only considers characters from position n onwards (0 = first position).


The sort command sorts the lines in one or more files and writes them out to the standard output. The same command can also merge several files (when used with the -m option) and can produce an appropriately sorted and merged output.