/sys/doc/ Documentation archive



SORT(I)                      5/13/75                      SORT(I)



NAME
     sort, usort - sort or merge files

SYNOPSIS
     sort [ -a_b_d_n_r_t_x ] [ +pos  [ -pos ] ] . . .  [ -mo ] [ name ]
     . . .
     usort [ -umo ] [ name ] . . .

DESCRIPTION
     Sort sorts all the named files together and writes  the  re-
     sult  on  the standard output.  The name `-' means the stan-
     dard input.  The standard input is also  used  if  no  input
     file names are given.  Thus sort may be used as a filter.

     The default sort key is an entire line.  Default ordering is
     lexicographic in ASCII collating sequence, except that  low-
     er-case letters are considered the same as the corresponding
     upper-case letters.  Non-ASCII bytes are ignored.   The  or-
     dering is affected by the flags abdnrt, one or more of which
     may appear:

     a   Do not map lower case letters.

     b   Leading blanks (spaces and tabs)  are  not  included  in
         fields.

     d   `Dictionary'  order: only letters, digits and blanks are
         significant in ASCII comparisons.

     n   An initial numeric string, consisting of optional  minus
         sign,  digits  and optionally included decimal point, is
         sorted by arithmetic value.

     r   Reverse the sense of comparisons.

     tx  Tab character between fields is x.

     Selected parts of the line, specified by +pos and -pos,  may
     be  used as sort keys.  Pos has the form m.n, where m speci-
     fies a number of fields to skip, and n a number  of  charac-
     ters to skip further into the next field.  A missing is tak-
     en to be 0.  +pos denotes the beginning of the key; -pos de-
     notes  the  first position after the key (end of line by de-
     fault).  The ordering rule may be overridden for a  particu-
     lar key by appending one or more of the flags abdnr to +pos.

     When no tab character has been specified, a  field  consists
     of  nonblanks  and any preceding blanks.  Under the -b flag,
     leading blanks are excluded from a field.  When a tab  char-
     acter  has been specified, a field is a string ending with a
     tab character.

     When keys are specified, later keys are compared  only  when
     all  earlier  ones  compare equal.  Lines that compare equal
     are ordered with all bytes significant.


                              - 1 -




SORT(I)                      5/13/75                      SORT(I)


     These flag arguments are also understood:

     -m  Merge only, the input files are already sorted.

     -o  The next argument is the name of an output file  to  use
         instead  of  the  standard output.  This file may be the
         same as one of the inputs, except under the  merge  flag
         -m.

     Usort  is  a  somewhat specialized version of sort which ac-
     cepts no collating sequence options: order is  always  plain
     ASCII.   It  also strips out the second and following copies
     of duplicated lines.  A  u  flag  prevents  this  stripping.
     Usort  also  understands the m and o options in the same way
     as sort.

FILES
     /usr/tmp/stm???

BUGS






































                              - 2 -