sort(1) — Linux manual page

NAME | SYNOPSIS | DESCRIPTION | AUTHOR | REPORTING BUGS | COPYRIGHT | SEE ALSO | COLOPHON

SORT(1)                       User Commands                       SORT(1)

NAME         top

       sort - sort lines of text files

SYNOPSIS         top

       sort [OPTION]... [FILE]...
       sort [OPTION]... --files0-from=F

DESCRIPTION         top

       Write sorted concatenation of all FILE(s) to standard output.

       With no FILE, or when FILE is -, read standard input.

       Mandatory arguments to long options are mandatory for short
       options too.  Ordering options:

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-b\-b, --ignore-leading-blanks]8;;\
              ignore leading blanks when finding sort keys in each line

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-d\-d, --dictionary-order]8;;\
              consider only blanks and alphanumeric characters

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-f\-f, --ignore-case]8;;\
              fold lower case to upper case characters

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-g\-g, --general-numeric-sort]8;;\
              compare according to general numerical value

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-i\-i, --ignore-nonprinting]8;;\
              consider only printable characters

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-M\-M, --month-sort]8;;\
              compare (unknown) < 'JAN' < ... < 'DEC'

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-h\-h, --human-numeric-sort]8;;\
              compare human readable numbers (e.g., 2K 1G)

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-n\-n, --numeric-sort]8;;\
              compare according to string numerical value; see full
              documentation for supported strings

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-R\-R, --random-sort]8;;\
              shuffle, but group identical keys.  See also shuf(1)

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort--random-source\--random-source=FILE]8;;\
              get random bytes from FILE

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-r\-r, --reverse]8;;\
              reverse the result of comparisons

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort--sort\--sort=WORD]8;;\
              sort according to WORD: general-numeric -g, human-numeric
              -h, month -M, numeric -n, random -R, version -V

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-V\-V, --version-sort]8;;\
              natural sort of (version) numbers within text

       Other options:

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort--batch-size\--batch-size=NMERGE]8;;\
              merge at most NMERGE inputs at once; for more use temp
              files

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-c\-c, --check, --check=diagnose-first]8;;\
              check for sorted input; do not sort

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-C\-C, --check=quiet, --check=silent]8;;\
              like -c, but do not report first bad line

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort--compress-program\--compress-program=PROG]8;;\
              compress temporaries with PROG; decompress them with PROG
              -d

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort--debug\--debug]8;;\
              annotate the part of the line used to sort, and warn about
              questionable usage to standard error

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort--files0-from\--files0-from=F]8;;\
              read input from the files specified by NUL-terminated names
              in file F; If F is -, read names from standard input

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-k\-k, --key=KEYDEF]8;;\
              sort via a key; KEYDEF gives location and type

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-m\-m, --merge]8;;\
              merge already sorted files; do not sort

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-o\-o, --output=FILE]8;;\
              write result to FILE instead of standard output

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-s\-s, --stable]8;;\
              stabilize sort by disabling last-resort comparison

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-S\-S, --buffer-size=SIZE]8;;\
              use SIZE for main memory buffer

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-t\-t, --field-separator=SEP]8;;\
              use SEP instead of non-blank to blank transition

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-T\-T, --temporary-directory=DIR]8;;\
              use DIR for temporaries, not $TMPDIR or /tmp; multiple
              options specify multiple directories

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort--parallel\--parallel=N]8;;\
              change the number of sorts run concurrently to N

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-u\-u, --unique]8;;\
              output only the first of lines with equal keys; with -c,
              check for strict ordering

       ]8;;https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-z\-z, --zero-terminated]8;;\
              line delimiter is NUL, not newline

       ]8;;https://www.gnu.org/software/coreutils/sort#sort--help\--help]8;;\ display this help and exit

       ]8;;https://www.gnu.org/software/coreutils/sort#sort--version\--version]8;;\
              output version information and exit

       KEYDEF is F[.C][OPTS][,F[.C][OPTS]] for start and stop position,
       where F is a field number and C a character position in the field;
       both are origin 1, and the stop position defaults to the line's
       end.  If neither -t nor -b is in effect, characters in a field are
       counted from the beginning of the preceding whitespace.  OPTS is
       one or more single-letter ordering options [bdfgiMhnRrV], which
       override global ordering options for that key.  If no key is
       given, use the entire line as the key.  Use --debug to diagnose
       incorrect key usage.

       SIZE may be followed by the following multiplicative suffixes: %
       1% of memory, b 1, K 1024 (default), and so on for M, G, T, P, E,
       Z, Y, R, Q.

       *** WARNING *** The locale specified by the environment affects
       sort order.  Set LC_ALL=C to get the traditional sort order that
       uses native byte values.

AUTHOR         top

       Written by Mike Haertel and Paul Eggert.

REPORTING BUGS         top

       Report bugs to: bug-coreutils@gnu.org
       GNU coreutils home page: <https://www.gnu.org/software/coreutils/>
       General help using GNU software: <https://www.gnu.org/gethelp/>
       Report any translation bugs to
       <https://translationproject.org/team/>

COPYRIGHT         top

       Copyright © 2026 Free Software Foundation, Inc.  License GPLv3+:
       GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
       This is free software: you are free to change and redistribute it.
       There is NO WARRANTY, to the extent permitted by law.

SEE ALSO         top

       shuf(1), uniq(1)

       Full documentation <https://www.gnu.org/software/coreutils/sort>
       or available locally via: info '(coreutils) sort invocation'

COLOPHON         top

       This page is part of the coreutils (basic file, shell and text
       manipulation utilities) project.  Information about the project
       can be found at ⟨http://www.gnu.org/software/coreutils/⟩.  If you
       have a bug report for this manual page, see
       ⟨http://www.gnu.org/software/coreutils/⟩.  This page was obtained
       from the tarball coreutils-9.11.tar.xz fetched from
       ⟨http://ftp.gnu.org/gnu/coreutils/⟩ on 2026-05-24.  If you
       discover any rendering problems in this HTML version of the page,
       or you believe there is a better or more up-to-date source for the
       page, or you have corrections or improvements to the information
       in this COLOPHON (which is not part of the original manual page),
       send a mail to man-pages@man7.org

GNU coreutils 9.11              April 2026                        SORT(1)

Pages that refer to this page: column(1)grep(1)look(1)prlimit(1)ps(1)rpmsort(1)sortman(1)uniq(1)qsort(3)strverscmp(3)environ(7)