

SORT                           04/15/78                          SORT 



NAME
       
       sort - sort and/or merge text files
       
SYNOPSIS

       sort [-bdfimr] [+ofile] [+sn] [file] ...
       
DESCRIPTION
       
       Sort sorts lines of all the named files together and writes the
       result on the standard output.  The name '-' means the standard
       input.   The standard input is also used if no input file names
       are given. Thus sort may be used as a filter.
       
       The sort key is an entire line. Default ordering is  alphabetic
       by  characters  as  they  are  represented in ASCII format. The
       ordering is affected by the following flags,  one  or  more  of
       which may appear.
       
        -b Leading blanks  are not included in keys.
           
        -d 'Dictionary'  order:  only  letters,  digits and blanks are
           significant in comparisons.
           
        -f Fold all letters to a single case.
           
        -i Ignore all nonprinting nonblank characters.
           
        -m Merge only, the input files are already sorted.
           
        -r Reverse the sense of the sort
           
        +o Cause final output to be placed on  `file'.   This  permits
           one  of the input files to be the output file.  This switch
           is necessary since using the redirection `>file' will cause
           `file' to be  unreadable  when  `sort'  is  generating  the
           initial runs.
           
       +sn Sort according to the subfield starting on column n
           
       
FILES
       
       A  series  of  scratch  files  are  generated  and subsequently
       deleted. Presently the files are named "STn"  where  "n"  is  a
       sequence number.
       
SEE ALSO
       


                                 -1-                                  


SORT                           04/15/78                          SORT 


       The Unix command "sort" in the Unix User's Manual.
       
DIAGNOSTICS
       
       A message is printed if a file cannot be located.
       
AUTHORS
       
       Original design from Kernighan and Plauger's "Software Tools", 
       with  modifications  by  Debbie  Scherrer.   The external merge
       phase of sort was completely rewritten by Joe Sventek.
       
BUGS
       
       The merge  phase  is  performed  with  a  polyphase  merge/sort
       algorithm,  which  requires  an  end-of-run  delimiter  on  the
       scratch files.  The one chosen is a bare ^D(ASCII code 4) on  a
       line.   If this is in conflict with your data files, the symbol
       CTRLD in sortsym should be redefined and sort built again.
       
       Eventually all the Unix "sort"  flags  should  be  implemented.
       These include:
            sort [-mubdfinrtx] [+pos] [-pos] [-o file] [file] ...
       
       The additional flags are:
       
            n  An initial numeric string, consisting of optional minus
       sign,  digits  and optionally included decimal point, is sorted
       by arithmetic value.
       
                 tx Tab character between fields is x.
       
            +pos -pos Selected parts of the line,  specified  by  +pos
       and  -pos,  may  be  used  as  sort keys.  Pos has the form m.n
       optionally followed by one or more of the flags bdfinr, where m
       specifies a number of fields to skip, n a number of  characters
       to  skip  further  into the next field, and the flags specify a
       special ordering rule for the key.  A missing . n is  taken  to
       be  0.  +pos denotes the beginning of the key; -pos denotes the
       first position after the key (end of line by  default).   Later
       keys  are  compared  only  when all earlier keys compare equal.
       Note:  The first field of a line is numbered zero.
       
       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 character has
       been specified, fields are strings separated by tab characters.
       
       Lines that otherwise compare equal are ordered with  all  bytes
       significant.
       


                                 -2-                                  


SORT                           04/15/78                          SORT 


            -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. {Note--it is
       not clear why this flag is needed.]
       
            -u Suppress  all  but  one in each set of contiguous equal
       lines.  Ignored bytes and bytes outside keys do not participate
       in this comparison.













































                                 -3-                                  

