Annotation of researchv10dc/man/adm/man1/sort.1, revision 1.1.1.1

1.1       root        1: .TH SORT 1 
                      2: .CT 1 files
                      3: .SH NAME
                      4: sort \- sort and/or merge files
                      5: .SH SYNOPSIS
                      6: .B sort
                      7: [
                      8: .BI -cmuMbdf\&inrt x
                      9: ]
                     10: [
                     11: .BI + pos1
                     12: [
                     13: .BI - pos2
                     14: ] ...
                     15: ]
                     16: [
                     17: .B -o
                     18: .I output
                     19: ]
                     20: [
                     21: .I option ...
                     22: ]
                     23: [
                     24: .I file ...
                     25: ]
                     26: .SH DESCRIPTION
                     27: .I Sort\^
                     28: sorts
                     29: lines of all the
                     30: .I files
                     31: together and writes the result on
                     32: the standard output.
                     33: The name
                     34: .B -
                     35: means
                     36: the standard input.
                     37: If no input files are named, the standard input is sorted.
                     38: .PP
                     39: The default sort key is an entire line.
                     40: Default ordering is
                     41: lexicographic by bytes in machine
                     42: collating sequence.
                     43: The ordering is affected globally by the following options,
                     44: one or more of which may appear.
                     45: .TP
                     46: .B -M
                     47: Compare as months.
                     48: The first three
                     49: non-white space characters
                     50: of the field
                     51: are folded
                     52: to lower case
                     53: and compared
                     54: so that
                     55: .L jan
                     56: precedes
                     57: .LR feb ,
                     58: etc.
                     59: Invalid fields
                     60: compare low to
                     61: .LR jan .
                     62: .TP
                     63: .B -b
                     64: Ignore leading white space (spaces and tabs) in field comparisons.
                     65: .TP
                     66: .B -d
                     67: `Phone directory' order: only letters, digits and white space
                     68: are significant in comparisons.
                     69: .TP
                     70: .B -f
                     71: Fold upper case
                     72: letters onto lower case.
                     73: .TP
                     74: .B -i
                     75: Ignore characters outside the
                     76: .SM ASCII
                     77: range 040-0176
                     78: in non-numeric comparisons.
                     79: .TP
                     80: .B -n
                     81: An initial numeric string,
                     82: consisting of optional white space, optional minus sign,
                     83: and zero or more digits with optional decimal point,
                     84: is sorted by arithmetic value.
                     85: Option
                     86: .B -n
                     87: implies option
                     88: .BR -b .
                     89: .TP
                     90: .B -g
                     91: Numbers, like
                     92: .B -n 
                     93: but with optional 
                     94: .BR e -style
                     95: exponents, are sorted by value.
                     96: .TP
                     97: .B -r
                     98: Reverse the sense of comparisons.
                     99: .TP
                    100: .BI -t x\^
                    101: `Tab character' separating fields is
                    102: .IR x .
                    103: .PP
                    104: The notation
                    105: .BI + "pos1\| " - pos2\^
                    106: restricts a sort key to a field beginning at
                    107: .I pos1\^
                    108: and ending just before
                    109: .IR pos2 .
                    110: .I Pos1\^
                    111: and
                    112: .I pos2\^
                    113: each have the form
                    114: .IB m . n ,
                    115: optionally followed by one or more of the flags
                    116: .BR Mbdfginr ,
                    117: where
                    118: .I m\^
                    119: tells a number of fields to skip from the beginning of the line and
                    120: .I n\^
                    121: tells a number of characters to skip further.
                    122: If any flags are present they override all the global
                    123: ordering options for this key.
                    124: A missing
                    125: .BI \&. n\^
                    126: means
                    127: .B \&.0;
                    128: a missing
                    129: .BI - pos2\^
                    130: means the end of the line.
                    131: Under the
                    132: .BI -t x\^
                    133: option, fields are strings separated by
                    134: .IR x ;
                    135: otherwise fields are
                    136: non-empty strings separated by white space.
                    137: White space before a field
                    138: is part of the field, except under option
                    139: .BR -b .
                    140: A
                    141: .B b
                    142: flag may be attached independently to
                    143: .IR pos1
                    144: and
                    145: .IR pos2.
                    146: .PP
                    147: When there are multiple sort keys, later keys
                    148: are compared only after all earlier keys
                    149: compare equal.
                    150: Lines that otherwise compare equal are ordered
                    151: with all bytes significant.
                    152: .PP
                    153: These option arguments are also understood:
                    154: .TP
                    155: .B -c
                    156: Check that the single input file is sorted according to the ordering rules;
                    157: give no output unless the file is out of sort.
                    158: .TP
                    159: .B -m
                    160: Merge; the input files are already sorted.
                    161: .TP
                    162: .B -u
                    163: Suppress all but one in each
                    164: set of equal lines.
                    165: Ignored bytes
                    166: and bytes outside keys
                    167: do not participate in
                    168: this comparison.
                    169: .TP
                    170: .B -o
                    171: The next argument is the name of an output file
                    172: to use instead of the standard output.
                    173: This file may be the same as one of the inputs.
                    174: .TP
                    175: .BI -T " tempdir
                    176: Put temporary files in
                    177: .I tempdir
                    178: rather than in (the default)
                    179: .BR /usr/tmp .
                    180: .TP
                    181: .BI -y memory
                    182: Suggests the use of the specified number of 
                    183: bytes of internal store in hopes of tuning performance;
                    184: 0 is appropriate for very small files, a missing
                    185: number for huge ones.
                    186: .TP
                    187: .BI -z recsize
                    188: Provide for abnormally large records;
                    189: useful only with
                    190: .B -c
                    191: and
                    192: .B -m
                    193: .SH EXAMPLES
                    194: .TP
                    195: .L sort -u +0f +0 list
                    196: Print in alphabetical order all the unique spellings
                    197: in a list of words
                    198: where capitalized words differ from uncapitalized.
                    199: .TP
                    200: .L sort -t: +2n /etc/passwd
                    201: Print the password file
                    202: .RI ( passwd (5))
                    203: sorted by userid
                    204: (the third colon-separated field).
                    205: .TP
                    206: .L sort -umM dates
                    207: Print the first instance of each month in an already sorted file.
                    208: Options
                    209: .B -um
                    210: with just one input file make the choice of a
                    211: unique representative from a set of equal lines predictable.
                    212: .TP
                    213: .L
                    214: grep -n '^' input | sort -t: +1f +0n | sed 's/[0-9]*://'
                    215: A stable sort: input lines that compare equal will 
                    216: come out in their original order.
                    217: .SH FILES
                    218: .F /usr/tmp/stm???
                    219: .SH SEE ALSO
                    220: .IR comm (1),
                    221: .IR join (1),
                    222: .IR uniq (1),
                    223: .IR look (1)
                    224: .SH DIAGNOSTICS
                    225: .I Sort
                    226: comments and exits with non-zero status for various trouble
                    227: conditions and for disorder discovered under option
                    228: .BR -c .
                    229: .SH BUGS
                    230: Option
                    231: .B -g
                    232: compares rounded floating binary values.
                    233: .br
                    234: Syntax needs overhauling.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.