SORT(1)

πŸ“¦
version 9.10 Β· 5 versions
, in ubuntu stonking

πŸ’– SORT(1) πŸ’–

okay bestie, welcome to sort(1) β€” a User Command, no big deal, just the lil tool that's been carrying your shell scripts since forever πŸ‘‘


✨ NAME ✨

sort β€” sort lines of text files 🌸


πŸŽ€ SYNOPSIS πŸŽ€

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

πŸ¦‹ DESCRIPTION πŸ¦‹

It writes the sorted concatenation of all FILE(s) to standard output. That's it. That's the whole vibe. 🫢

If you give it no FILE at all, or if FILE is literally just -, it reads standard input. slay.

Mandatory arguments to long options are mandatory for short options too. (yes, fr fr, it means what it says πŸ’…)

πŸ”₯ Ordering options πŸ”₯

  • -b, --ignore-leading-blanks β€” ignore leading blanks when it's out here finding sort keys in each line ✨
  • -d, --dictionary-order β€” only considers blanks and alphanumeric characters, nothing else invited to the party
  • -f, --ignore-case β€” folds lower case into upper case characters, capitalization drama deleted πŸ’€
  • -g, --general-numeric-sort β€” compares according to general numerical value
  • -i, --ignore-nonprinting β€” only printable characters count, the rest are invisible bestie πŸ™ˆ
  • -M, --month-sort β€” compares (unknown) < 'JAN' < ... < 'DEC' β€” calendar girl energy πŸ“…
  • -h, --human-numeric-sort β€” compares human readable numbers, like 2K, 1G β€” the numbers your brain actually understands πŸ‘‘
  • -n, --numeric-sort β€” compares according to string numerical value; see the full documentation for supported strings πŸ“–
  • -R, --random-sort β€” shuffle, but group identical keys. See also shuf(1) 🎲
  • --random-source=FILE β€” get random bytes from FILE, so your chaos is reproducible
  • -r, --reverse β€” reverse the result of comparisons, flip the whole fit πŸ”„
  • --sort=WORD β€” sort according to WORD: general-numeric -g, human-numeric -h, month -M, numeric -n, random -R, version -V
  • -V, --version-sort β€” natural sort of (version) numbers within text, so v2 comes before v10 like a civilized person 🌈

πŸ’œ Other options πŸ’œ

  • --batch-size=NMERGE β€” merge at most NMERGE inputs at once; for more use temp files
  • -c, --check, --check=diagnose-first β€” check for sorted input; do not sort. it's just looking, not touching πŸ‘€
  • -C, --check=quiet, --check=silent β€” like -c, but do not report first bad line 🀫
  • --compress-program=PROG β€” compress temporaries with PROG; decompress them with PROG -d
  • --debug β€” annotate the part of the line used to sort, and warn about questionable usage to standard error πŸ›
  • --files0-from=F β€” read input from the files specified by NUL-terminated names in file F; if F is -, read names from standard input
  • -k, --key=KEYDEF β€” sort via a key; KEYDEF gives location and type πŸ”‘
  • -m, --merge β€” merge already sorted files; do not sort. they're already iconic, just line them up
  • -o, --output=FILE β€” write result to FILE instead of standard output
  • -s, --stable β€” stabilize sort by disabling last-resort comparison, so ties stay in their original order, periodt
  • -S, --buffer-size=SIZE β€” use SIZE for main memory buffer
  • -t, --field-separator=SEP β€” use SEP instead of non-blank to blank transition
  • -T, --temporary-directory=DIR β€” use DIR for temporaries, not $TMPDIR or /tmp; multiple options specify multiple directories
  • --parallel=N β€” change the number of sorts run concurrently to N
  • -u, --unique β€” output only the first of lines with equal keys; with -c, check for strict ordering
  • -z, --zero-terminated β€” line delimiter is NUL, not newline
  • --help β€” display this help and exit
  • --version β€” output version information and exit

🧚 KEYDEF, explained (iykyk) 🧚

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 suffixes πŸ“

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. ⚠️ bestie this one bites people every single day, do not skip it

πŸ‘‘ AUTHOR πŸ‘‘

Written by Mike Haertel and Paul Eggert. legends, honestly.


😭 REPORTING BUGS 😭

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/>


🌈 SEE ALSO 🌈

shuf(1), uniq(1)

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


Packaged by Ubuntu (9.10-1ubuntu2) 🐧 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.


okay that's the whole page, you ate that 🫢 this version came from GNU coreutils 9.10, dated August 2026 β€” go forth and sort, main character πŸ’…βœ¨

πŸ“¦ where this page comes from