V10/cmd/sort/sort.1

Compare this file to the similar file:
Show the results in this format:




     SORT(1)                                                   SORT(1)



     NAME
          sort - sort and/or merge files

     SYNOPSIS
          sort [ -cmuMbdfinrt_x ] [ -o _o_u_t_p_u_t ] [ _o_p_t_i_o_n ... ] [ _f_i_l_e
          ... ]

     DESCRIPTION
          _S_o_r_t sorts lines of all the _f_i_l_e_s together and writes the
          result on the standard output.  The name - means the stan-
          dard input.  If no input files are named, the standard input
          is sorted.

          The default sort key is an entire line.  Default ordering is
          lexicographic by bytes in machine collating sequence.  The
          ordering is affected globally by the following options, one
          or more of which may appear.

          -b   Ignore leading white space (spaces and tabs) in field
               comparisons.

          -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 optional white space are folded to lower case and
               compared.  Invalid fields compare low to `jan'.

          -r   Reverse the sense of comparisons.

          -t_x  `Tab character' separating fields is _x.

          -k _p_o_s_1,_p_o_s_2
               Restrict the sort key to a string beginning at _p_o_s_1 and
               ending at _p_o_s_2.  _P_o_s_1 and _p_o_s_2 each have the form _m._n,
               optionally followed by one or more of the flags
               Mbdfginr; _m counts fields from the beginning of the
               line and _n counts characters from the beginning of the
               field.  If any flags are present they override all the
               global ordering options for this key.  If ._n is missing
               from _p_o_s_1, it is taken to be 1; if missing from _p_o_s_2,



     Page 1                    Tenth Edition         (printed 3/11/93)






     SORT(1)                                                   SORT(1)



               it is taken to be the end of the field.  If _p_o_s_2 is
               missing, it is taken to be end of line.

          Under option -t_x fields are strings separated by _x; other-
          wise 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
          _p_o_s_1 and _p_o_s_2.

          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 combina-
          tion 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 ordering 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 _o_u_t_p_u_t
               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 _f_i_l_e argu-
               ments, except after --.

          -T _t_e_m_p_d_i_r
               Put temporary files in _t_e_m_p_d_i_r rather than in (the
               default) /usr/tmp.

          -ymemory
               Suggests using the specified number of bytes of inter-
               nal store to tune performance; an unspecified _m_e_m_o_r_y
               size is taken to be huge.

          +_p_o_s_1 -_p_o_s_2
               Classical alternative to -k, with counting from 0
               instead of 1, and _p_o_s_2 designating next-after-last
               instead of last character of the key.  A missing



     Page 2                    Tenth Edition         (printed 3/11/93)






     SORT(1)                                                   SORT(1)



               character count in _p_o_s_2 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
          `sort -u -k1f -k1 list'
               Print in alphabetical order all the unique spellings in
               a list of words where capitalized words differ from
               uncapitalized.

          `sort -t: -k3n /etc/passwd'
               Print the password file (_p_a_s_s_w_d(5)) sorted by userid
               (the third colon-separated field).

          `sort -umM dates'
               Print the first instance of each month in an already
               sorted file.

     FILES
          /usr/tmp/stm???

     SEE ALSO
          _c_o_m_m(1), _j_o_i_n(1), _u_n_i_q(1), _l_o_o_k(1)

     DIAGNOSTICS
          _S_o_r_t comments and exits with non-zero status for various
          trouble conditions and for disorder discovered under option
          -c.

     BUGS
          The never-documented default _p_o_s_1=0 for cases such as sort
          -1 has been abolished.
          Trouble (e.g. crash or file-system overflow) encountered
          while overwriting an input with -o is irrecoverable.




















     Page 3                    Tenth Edition         (printed 3/11/93)