*** UNIX MANUAL PAGE BROWSER ***

A Nergahak database for man pages research.

Navigation

Directory Browser

1Browse 4.4BSD4.4BSD
1Browse Digital UNIXDigital UNIX 4.0e
1Browse FreeBSDFreeBSD 14.3
1Browse MINIXMINIX 3.4.0rc6-d5e4fc0
1Browse NetBSDNetBSD 10.1
1Browse OpenBSDOpenBSD 7.7
1Browse UNIX v7Version 7 UNIX
1Browse UNIX v10Version 10 UNIX

Manual Page Search

Manual Page Result

0 Command: sort | Section: 1 | Source: UNIX v10 | File: sort.1
SORT(1) General Commands Manual SORT(1) NAME sort - sort and/or merge files SYNOPSIS sort [ -cmusMbdfinrtx ] [ -o output ] [ option ... ] [ file ... ] DESCRIPTION Sort sorts lines of all the files together and writes the result on the standard output. The name - means the standard input. If no input files are named, the standard input is sorted. The default sort key is an entire line. Default ordering is lexico- graphic by bytes in machine collating sequence. The ordering is af- fected globally by the following options, one or more of which may ap- pear. -b Ignore leading white space (spaces and tabs) in field compar- isons. -d `Phone directory' order: only letters, digits and white space are significant in string comparisons. -f Fold lower case letters onto upper case. -i Ignore characters outside the ASCII range 040-0176 in string comparisons. -n An initial numeric string, consisting of optional white space, optional sign, and a nonempty string of digits with optional decimal point, is sorted by value. -g Numeric, like -n, with e-style exponents allowed. -M Compare as month names. The first three characters after op- tional white space are folded to lower case and compared. In- valid fields compare low to -r Reverse the sense of comparisons. -tx `Tab character' separating fields is x. -k pos1,pos2 Restrict the sort key to a string beginning at pos1 and ending at pos2. Pos1 and pos2 each have the form m.n, optionally fol- lowed by one or more of the flags Mbdfginr; m counts fields from the beginning of the line and n counts characters from the be- ginning of the field. If any flags are present they override all the global ordering options for this key. If .n is missing from pos1, it is taken to be 1; if missing from pos2, it is taken to be the end of the field. If pos2 is missing, it is taken to be end of line. Under option -tx fields are strings separated by x; otherwise fields are non-empty strings separated by white space. White space before a field is part of the field, except under option -b. A b flag may be attached independently to pos1 and pos2. When there are multiple sort keys, later keys are compared only after all earlier keys compare equal. Except under option -s, lines with all keys equal are ordered with all bytes significant. Single-letter options may be combined into a single string, such as -cnrt:. The option combination -di and the combination of -n with any of -diM are improper. Posix argument conventions are supported. These option arguments are also understood: -c Check that the single input file is sorted according to the or- dering rules; give no output unless the file is out of sort. -m Merge; the input files are already sorted. -u Unique. Keep only the first of two lines that compare equal on all keys. Implies -s. -s Stable sort. When all keys compare equal, preserve input order. Unaffected by -r. -o output Place output in a designated file instead of on the standard output. This file may be the same as one of the inputs. The option may appear among the file arguments, except after --. -T tempdir Put temporary files in tempdir rather than in (the default) /usr/tmp. -ymemory Suggests using the specified number of bytes of internal store to tune performance; an unspecified memory size is taken to be huge. +pos1 -pos2 Classical alternative to -k, with counting from 0 instead of 1, and pos2 designating next-after-last instead of last character of the key. A missing character count in pos2 means 0, which in turn excludes any -t tab character from the end of the key. Thus +1 -1.3 means the same as -k 2,2.3 and +1r -3 means the same as -k 2r,3. EXAMPLES Print in alphabetical order all the unique spellings in a list of words where capitalized words differ from uncapi- talized. Print the password file (passwd(5)) sorted by userid (the third colon-separated field). Print the first instance of each month in an already sorted file. FILES SEE ALSO comm(1), join(1), uniq(1), look(1) DIAGNOSTICS Sort comments and exits with non-zero status for various trouble condi- tions and for disorder discovered under option -c. BUGS The never-documented default pos1=0 for cases such as sort -1 has been abolished. Trouble (e.g. crash or file-system overflow) encountered while over- writing an input with -o is irrecoverable. SORT(1)

Navigation Options