SORT(1)

✨ SORT(1) ✨ β€” it's giving manual page, bestie πŸ’…

okay so real talk, this is sort from the General Commands Manual, and it's lowkey one of the most iconic little tools ever. she's been in the group chat since forever and she never misses. let's get into it 🫢


🌸 NAME 🌸

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

no cap, that's the whole vibe: give her files, she gives you them back, but sorted. give her nothing (or a -, bestie, a literal dash) and she'll just read from standard input like the chill queen she is. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

sort [OPTION]... [FILE]...

that's it. options, then files. the dots mean "as many as you want." main character energy, truly. ✨


🌈 DESCRIPTION 🌈

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

fr fr, that's the entire job description and she executes it flawlessly every single time. πŸ’…


πŸŽ€ OPTIONS πŸŽ€

not me listing every single one because I would never skip a flag. obsessed with thoroughness actually.

  • --help β€” Print help information.
  • --version β€” Print version information.
  • --sort β€” pick your sorting vibe. 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 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 β€” sort by a key
  • -t, --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
  • [files]

πŸ’œ EXTRA πŸ’œ

the key stuff. the part everyone googles and nobody remembers. iykyk 😭

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.

okay so memorize MbdfhnRrV and you're basically a sort wizard. no cap. πŸ”₯

⭐ VERSION ⭐

v(uutils coreutils) 0.12.0


πŸ”₯ EXAMPLES πŸ”₯

she ate every single one of these, so here's the whole menu bestie:

Sort a file in ascending order:

sort path/to/file

Sort a file in descending order:

sort [-r|--reverse] path/to/file

Sort a file in case-insensitive way:

sort [-f|--ignore-case] path/to/file

Sort a file using numeric rather than alphabetic order:

sort [-n|--numeric-sort] path/to/file

Sort /etc/passwd by the 3rd field onward of each line numerically, using : as a field separator:

sort [-t|--field-separator] : [-k|--key] 3n /etc/passwd

As above, but when items in the 3rd field are equal, sort by the 4th field by numbers with exponents:

sort [-t|--field-separator] : [-k|--key] 3,3n [-k|--key] 4,4g
/etc/passwd

Sort a file preserving only unique lines:

sort [-u|--unique] path/to/file

Sort a file, printing the output to the specified output file (can be used to sort a file in-place):

sort [-o|--output] path/to/output_file path/to/input_file

The examples are provided by the tldr-pages project <https://tldr.sh> under the CC BY 4.0 License. Please note that, as uutils is a work in progress, some examples might fail.

πŸ’€ that last bit is real, okay, don't come for her β€” uutils is still cooking. some examples might not work yet. be nice. πŸ₯Ί

and that's the whole page bestie!! πŸŽ€ this one's SORT(1) from the General Commands Manual, v(uutils coreutils) 0.12.0, dated 2026-09-25. periodt. go sort something gorgeous. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from