OS Manuals

/usr/bin/sort

Cross-platform Rust rewrite of the GNU coreutils.

From uutils 0.12.0-r6 (os), captured 2026-11-07 by running sort --help (exit 0). permalink

Display sorted concatenation of all FILE(s). With no FILE, or when FILE is -, read standard input.

Usage: sort [OPTION]... [FILE]...

Arguments:
  [files]...

Options:
      --help
          Print help information.
      --version
          Print version information.
      --sort <sort>
          [possible values: general-numeric, human-numeric, month, numeric, version, random]
  -h, --human-numeric-sort
          compare according to human readable sizes, eg 1M > 100k
  -M, --month-sort
          compare according to month name abbreviation
  -n, --numeric-sort
          compare according to string numerical value
  -g, --general-numeric-sort
          compare according to string general numerical value
  -V, --version-sort
          Sort by SemVer version number, eg 1.12.2 > 1.1.2
  -R, --random-sort
          shuffle in random order
      --random-source <FILE>
          use FILE as a source of random data
  -d, --dictionary-order
          consider only blanks and alphanumeric characters
  -m, --merge
          merge already sorted files; do not sort
  -c, --check[=<check>...]
          check for sorted input; do not sort [possible values: silent, quiet, diagnose-first]
  -C, --check-silent
          exit successfully if the given file is already sorted, and exit with status 1 otherwise.
  -f, --ignore-case
          fold lower case to upper case characters
  -i, --ignore-nonprinting
          ignore nonprinting characters
  -b, --ignore-leading-blanks
          ignore leading blanks when finding sort keys in each line
  -o, --output <FILENAME>
          write output to FILENAME instead of stdout
  -r, --reverse
          reverse the output
  -s, --stable
          stabilize sort by disabling last-resort comparison
  -u, --unique
          output only the first of an equal run
  -k, --key <key>
          sort by a key
  -t, --field-separator <field-separator>
          custom separator for -k
  -z, --zero-terminated
          line delimiter is NUL, not newline
      --parallel <NUM_THREADS>
          change the number of threads running concurrently to NUM_THREADS
  -S, --buffer-size <SIZE>
          sets the maximum SIZE of each segment in number of sorted items
  -T, --temporary-directory <DIR>
          use DIR for temporaries, not $TMPDIR or /tmp
      --compress-program <PROG>
          compress temporary files with PROG, decompress with PROG -d; PROG has to take input from
          stdin and output to stdout
      --batch-size <N_MERGE>
          Merge at most N_MERGE inputs at once.
      --files0-from <NUL_FILE>
          read input from the files specified by NUL-terminated NUL_FILE
      --debug
          underline the parts of the line that are actually used for sorting

The key format is FIELD[.CHAR][OPTIONS][,FIELD[.CHAR]][OPTIONS].

Fields by default are separated by the first whitespace after a non-whitespace character. Use -t to
specify a custom separator.
In the default case, whitespace is appended at the beginning of each field. Custom separators
however are not included in fields.

FIELD and CHAR both start at 1 (i.e. they are 1-indexed). If there is no end specified after a
comma, the end will be the end of the line.
If CHAR is set 0, it means the end of the field. CHAR defaults to 1 for the start position and to 0
for the end position.

Valid options are: MbdfhnRrV. They override the global options for this key.
Options (31)
OptionDescriptionSource
--helpPrint help information.help + man
--versionPrint version information.help + man
--sort sort[possible values: general-numeric, human-numeric, month, numeric, version, random]help + man
-h, --human-numeric-sortcompare according to human readable sizes, eg 1M > 100khelp + man
-M, --month-sortcompare according to month name abbreviationhelp + man
-n, --numeric-sortcompare according to string numerical valuehelp + man
-g, --general-numeric-sortcompare according to string general numerical valuehelp + man
-V, --version-sortSort by SemVer version number, eg 1.12.2 > 1.1.2help + man
-R, --random-sortshuffle in random orderhelp + man
--random-source FILEuse FILE as a source of random datahelp + man
-d, --dictionary-orderconsider only blanks and alphanumeric charactershelp + man
-m, --mergemerge already sorted files;help + man
-c, --check check>...check for sorted input;help + man
-C, --check-silentexit successfully if the given file is already sorted, and exit with status 1 otherwise.help + man
-f, --ignore-casefold lower case to upper case charactershelp + man
-i, --ignore-nonprintingignore nonprinting charactershelp + man
-b, --ignore-leading-blanksignore leading blanks when finding sort keys in each linehelp + man
-o, --output FILENAMEwrite output to FILENAME instead of stdouthelp + man
-r, --reversereverse the outputhelp + man
-s, --stablestabilize sort by disabling last-resort comparisonhelp + man
-u, --uniqueoutput only the first of an equal runhelp + man
-k, --key keysort by a keyhelp + man
-t, --field-separator field-separatorcustom separator for -khelp + man
-z, --zero-terminatedline delimiter is NUL, not newlinehelp + man
--parallel NUM_THREADSchange the number of threads running concurrently to NUM_THREADShelp + man
-S, --buffer-size SIZEsets the maximum SIZE of each segment in number of sorted itemshelp + man
-T, --temporary-directory DIRuse DIR for temporaries, not $TMPDIR or /tmphelp + man
--compress-program PROGcompress temporary files with PROG, decompress with PROG -d;help + man
--batch-size N_MERGEMerge at most N_MERGE inputs at once.help + man
--files0-from NUL_FILEread input from the files specified by NUL-terminated NUL_FILEhelp + man
--debugunderline the parts of the line that are actually used for sortinghelp + man

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.