home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource4 / 224_01 / sort.hlp < prev    next >
Encoding:
Text File  |  1987-01-02  |  2.5 KB  |  65 lines

  1. NAME
  2.      sort - sort or merge files
  3.  
  4. SYNTAX
  5.      sort [-bfnr] [+pos1 [-pos2]] [-o name] [-t path] [file_list]
  6.  
  7. DESCRIPTION
  8.     Sort sorts lines of all the named files together and writes the result 
  9.     on the standard output.  The name `-' means the standard input.  If no 
  10.     input files are named, the standard input is sorted.
  11.  
  12.     The default sort key is an entire line.  Default ordering is lexicographic
  13.     by bytes. The ordering is affected globally by the following options, one 
  14.     or more of which may appear.
  15.  
  16.     b   Ignore leading blanks (spaces and tabs) in field comparisons.
  17.  
  18.     f   Fold upper case letters onto lower case.
  19.  
  20.     n   An initial numeric string, consisting of optional blanks, optional 
  21.     minus sign, and zero or more digits with optional decimal point, is 
  22.     sorted by arithmetic value.  Option n implies option b.
  23.  
  24.     r   Reverse the sense of comparisons.
  25.  
  26.     The notation +pos1 -pos2 restricts a sort key to a field beginning at 
  27.     pos1 and ending just before pos2.  Pos1 and pos2 each have the form m.n 
  28.     where m tells a number of fields to skip from the beginning of the line 
  29.     and n tells a number of characters to skip further.  A missing .n means .0;
  30.     a missing -pos2 means the end of the line.  Fields are nonempty nonblank 
  31.     strings separated by blanks, where blanks include the characters SP and HT
  32.     (' ' and ^I).
  33.  
  34.     When there are multiple sort keys, later keys are compared only after all 
  35.     earlier keys compare equal.  Lines that otherwise compare equal are ordered
  36.     with all bytes significant.
  37.  
  38.     These option arguments are also understood:
  39.  
  40.     o   The next argument is the name of an output file to use instead of the 
  41.     standard output.  This file may be the same as one of the inputs.
  42.  
  43.     t   The next argument is the name of a path (drive, directory) in which 
  44.     temporary files should be made.  Temporary files will only be created
  45.     when the number of input lines exceed 1000 lines. 
  46.  
  47. EXAMPLES
  48.     Print in alphabetical order a list of words.  Capitalized words are grouped
  49.     with uncapitalized words.
  50.  
  51.     sort -bf list
  52.  
  53.     Print in reverse numerical order (large numbers first) a directory 
  54.     listing.
  55.  
  56.     ls -s | sort -nr +1
  57.  
  58. FILES
  59.     Temporary files have the name sorttemp.xxx where xxx is a number from 0 to
  60.     999.  These files are deleted if sort successfully completes (i.e. if the 
  61.     user doesn't interrupt the program).
  62.  
  63. SEE ALSO
  64.      uniq, comm, rev
  65.