SORT(1)
๐ SORT(1) ๐
okay bestie, welcome to the sort manual page โ it lives in the User Commands section and it is genuinely one of the most iconic little gremlins in your whole toolkit. let's get into it ๐ซถ
โจ NAME โจ
sort โ sort lines of text files
๐ธ SYNOPSIS ๐ธ
sort [OPTION]... [FILE]...
sort [OPTION]... --files0-from=F
๐ฆ DESCRIPTION ๐ฆ
So what it does: it writes the sorted concatenation of all the FILE(s) to standard output. that's it. that's the whole vibe. โจ
If you give it no FILE, or if FILE is -, it reads from standard input. very demure, very mindful. ๐
Also, mandatory arguments to long options are mandatory for short options too. like, don't try it. it's not optional. periodt.
๐ Ordering options
-b,--ignore-leading-blanksโ ignore leading blanks when finding sort keys in each line. yes queen, skip the whitespace ๐-d,--dictionary-orderโ only consider blanks and alphanumeric characters. everything else? not invited to the function ๐ซ-f,--ignore-caseโ fold lower case to upper case characters. case? we don't know her ๐ฅ-g,--general-numeric-sortโ compare according to general numerical value. the math-y one ๐งฎ-i,--ignore-nonprintingโ consider only printable characters. invisible stuff, be gone ๐ซฅ-M,--month-sortโ compare(unknown) < 'JAN' < ... < 'DEC'. literally a calendar girl moment ๐-h,--human-numeric-sortโ compare human readable numbers (e.g.,2K1G). for the girlies who say "2K" instead of "2048" ๐-n,--numeric-sortโ compare according to string numerical value; see full documentation for supported strings. ngl the docs are where the details live ๐-R,--random-sortโ shuffle, but group identical keys. See alsoshuf(1). chaos, but organized chaos ๐ฒ--random-source=FILEโ get random bytes fromFILE. your randomness has a source now โจ-r,--reverseโ reverse the result of comparisons. plot twist ๐--sort=WORDโ sort according toWORD:general-numeric-g,human-numeric-h,month-M,numeric-n,random-R,version-V. one option, six personalities ๐-V,--version-sortโ natural sort of (version) numbers within text. sov2comes beforev10, as it should ๐
๐ Other options
--batch-size=NMERGEโ merge at mostNMERGEinputs at once; for more use temp files. don't overbook the merge bestie ๐-c,--check,--check=diagnose-firstโ check for sorted input; do not sort. just vibes and judgement ๐-C,--check=quiet,--check=silentโ like-c, but do not report first bad line. silent but deadly ๐คซ--compress-program=PROGโ compress temporaries withPROG; decompress them withPROG -d. glow-up via compression ๐--debugโ annotate the part of the line used to sort, and warn about questionable usage to standard error. the friend who tells you the truth ๐ซถ--files0-from=Fโ read input from the files specified by NUL-terminated names in fileF; IfFis-, read names from standard input. NUL-terminated, not newline-terminated, important bestie โ ๏ธ-k,--key=KEYDEFโ sort via a key;KEYDEFgives location and type. the main character option fr fr ๐-m,--mergeโ merge already sorted files; do not sort. it trusts you. don't betray it ๐ญ-o,--output=FILEโ write result toFILEinstead of standard output. redirect, but make it chic ๐-s,--stableโ stabilize sort by disabling last-resort comparison. stable like your fave ๐ธ-S,--buffer-size=SIZEโ useSIZEfor main memory buffer. feed the machine ๐-t,--field-separator=SEPโ useSEPinstead of non-blank to blank transition. custom separator, custom era โ๏ธ-T,--temporary-directory=DIRโ useDIRfor temporaries, not$TMPDIRor/tmp; multiple options specify multiple directories. hoard directories, why not ๐--parallel=Nโ change the number of sorts run concurrently toN. multitasking queen ๐ซ-u,--uniqueโ output only the first of lines with equal keys; with-c, check for strict ordering. duplicates? never met her ๐ซ-z,--zero-terminatedโ line delimiter is NUL, not newline. NUL gang rise up ๐ซก--helpโ display this help and exit. the classic ๐--versionโ output version information and exit. the other classic ๐
๐ KEYDEF, explained (the part everyone skips and then regrets)
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. lowkey feral but okay ๐
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. seriously. do it. it will save your whole evening ๐ญ
๐ง 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. not me finding out my sort order was locale-coded the whole time ๐
๐ AUTHOR ๐
Written by Mike Haertel and Paul Eggert. legends, honestly ๐
๐ข REPORTING BUGS ๐ข
- Report bugs to: <bug-coreutils@gnu.org>.
- Report any translation bugs to: <https://translationproject.org/team/>.
- GNU coreutils home page: <https://www.gnu.org/software/coreutils/>
- General help using GNU software: <https://www.gnu.org/gethelp/>
โญ COPYRIGHT โญ
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 ๐ฆ
Full documentation <https://www.gnu.org/software/coreutils/sort> or available locally via: info '(coreutils) sort invocation'
and that's the whole page bestie ๐ this was GNU coreutils 9.12, dated September 2026 โ go forth and sort your lines, you absolute icon, no cap ๐โจ๐ฆ
๐ฆ where this page comes from
- arch rolling: coreutils 9.12-2 ยท GPL-3.0-or-later AND GFDL-1.3-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms