home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / open / head.lzh / HEAD.DOC < prev    next >
Text File  |  1986-01-22  |  7KB  |  158 lines

  1.  HEAD - a UNIX-like Utility                                       Page 1
  2.  
  3.      HEAD.EXE is a UNIX-like utility that will display the first 5 lines (by
  4.   default) of specified text files.  There are several switches that allow
  5.   you to control the output.  The HEAD command available in UNIX systems (at
  6.   least under 4.2 BSD) simply lists the first "n" lines of specified files,
  7.   and will run them together on output.  This MSDOS version of HEAD can do
  8.   that also, but has some additional features.
  9.  
  10.      I wrote HEAD because of a terrible mistake I made.  I had files on my
  11.   Winchester drive that I had not backed up; one of these files was a 20
  12.   page document that was very important.  Of course the hard disk crashed
  13.   (of course at 2 mins. before quitting time on a Friday night...), and was
  14.   so badly scrambled, that I had to clean out the disk with CHKDSK /F and
  15.   then go through the resulting 2 meg of FILE????.CHK files (each file
  16.   between 2 and 12K in size).  After writing a routine to discover which of
  17.   these files were pieces of binary files (i.e., largely non-printable ascii
  18.   stuff) and deleting them, I still had a large number of files to go
  19.   through and figure out which files could be used to recreate the important
  20.   document.  With HEAD I can list out the file names and the first few lines
  21.   of each file, and by referring to the printed copy of the original
  22.   document (yes, at least I had that) I could determine the correct order in
  23.   which to append files.
  24.  
  25.      HEAD may be invoked as follows:
  26.  
  27.   HEAD filespec [-L [-T [-H [-N [-#]]]]]
  28.  
  29.      The option switches may appear in any order, and may precede or follow
  30.   the file specification.  The switches may be in upper or lower case, and
  31.   MUST be preceded (without intervening spaces) by either a dash (-) or a
  32.   slash (/).  The file specifications may include any valid drive,
  33.   optionally followed by any valid directory specifications, followed by any
  34.   valid file name with extension.  The file name and extension may contain
  35.   wildcards.  HEAD will not accept the slash (/) as subdirectory separator,
  36.   which may cause you grief if you have specified the SWITCHAR as the dash
  37.   (-) in your CONFIG.SYS.  I may change this to allow only the (-) as an
  38.   option flag and either (\) or (/) as the subdirectory separator in the
  39.   next version of HEAD.
  40.  
  41.      The options you may select from are:
  42.  
  43.     -  -h Print a file name header for each file displayed.  Each file
  44.        displayed will be preceded by a line containing the file name, and a
  45.        blank line.
  46.  
  47.     -  -l Print the line number with each line displayed.
  48.  
  49.     -  -n End each line displayed with an additional newline.
  50.  
  51.     -  -t Translate down (by decimal 128) all ascii characters with an ascii
  52.        value greater than 127 (decimal).  This effectively removes the soft
  53.        carriage returns (ascii 141) produced by many word processors, and
  54.        other such things that don't always display nicely to the screen.
  55.        This does NOT mean that a soft carriage return will be replaced with
  56.        a hard carriage return AND line feed; this is only a simple shifting
  57.        down of the ascii value of existing characters.
  58.  
  59.     -  -# Don't really enter the number sign (#); rather, enter the number of
  60.        lines you wish displayed from each file.  The default value is set to
  61.        5.
  62.  HEAD - a UNIX-like Utility                                      Page 2
  63.  
  64.   
  65.      You may enter the options together (e.g., -hl20) or separately (e.g.,
  66.   -h -l -20).  If entered separately, each switch must be preceeded by a
  67.   space and a switch character (- or /).  The command line is scanned for
  68.   ALL option switches first, so options may preceed or follow or be
  69.   interspersed with the file specifications.
  70.  
  71.      You must enter a file specification!  The program will stop with a usage
  72.   message if you fail to give it a file specification.  You may give it more
  73.   than one file specification.  HEAD will expand all wildcard
  74.   specifications, unless it is unable to find any files matching the
  75.   specification.  In that case, it will report (e.g. for HEAD *.bak)
  76.   
  77.   "HEAD: could not find any file *.bak"
  78.   
  79.      There is a similar caveat for the specification of the number of lines
  80.   to be printed -- if you specify this option more than once, the last
  81.   specification is used, the others are discarded.
  82.  
  83.      You may also redirect the output, to a printer or to a file, e.g.,
  84.  
  85.   HEAD bozo.dat -l -h > prn
  86.  
  87.   to send output to the printer.  You should also be able to pipe output to
  88.   other programs (e.g., HEAD -10 *.DOC | SORT)
  89.  
  90.      The following examples may be of some help.
  91.  
  92.    HEAD -l -15 E:\CLIB\SOURCE\*.C -h
  93.  
  94.      would display the first fifteen (-15) lines with line numbers (-l) of
  95.   all files ending with the extension ".C" on drive E in the subdirectory
  96.   SOURCE of the subdirectory CLIB, preceding each file's output with a header
  97.   line giving the file name.
  98.  
  99.   HEAD autoexec.ba?
  100.  
  101.      would display the first 5 lines (the default) of all files on the
  102.   default drive and current directory with a name of "autoexec" and an
  103.   extension that begain with ".ba" (e.g., .BAK and .BAT).
  104.  
  105.   HEAD *.doc -20 -t -8
  106.   or
  107.   HEAD -20 *.doc -t8
  108.   or
  109.   HEAD -20t8 *.doc
  110.  
  111.      would list the first 8 lines of all files with the extension ".DOC" on
  112.   the current drive and directory.  Note that the -20 is ignored, the -8 is
  113.   accepted since it is the most recent setting specified.  All characters
  114.   greater than 127 decimal ascii value would be translated down by decimal
  115.   128.
  116.  
  117.   HEAD -h -l
  118.  
  119.      would produce an error message, informing you that you must specify a
  120.   file or files.
  121.  
  122.   HEAD
  123.  HEAD - a UNIX-like Utility                                      Page 3
  124.  
  125.  
  126.      would produce a usage message, telling you what it wants.
  127.  
  128.   HEAD file1.txt file2.txt
  129.  
  130.      would display the first 5 lines (default) of file1.txt, with no header
  131.   line, and no line numbers, followed immediately by the first 5 lines of
  132.   file2.txt.
  133.  
  134.   HEAD -h nosuch.fil
  135.  
  136.      assuming "nosuch.fil" does not exist, HEAD will tell you it couldn't
  137.   find file nosuch.fil.  
  138.  
  139.      HEAD was written in C and originally compiled using Computer
  140.   Innovation's C86 compiler (v 2.30), which seems to be a very nice
  141.   compiler.  The current version (2.1) was compiled using Microsoft C
  142.   version 3.0 which produces smaller code.
  143.  
  144.      DISCLAIMER: I can't promise that the program will work as you expect it
  145.   to; I've had few problems with it.  This is really the first version, and
  146.   I'm sure as it is used, people will find things that it could do better, or
  147.   correctly, etc..  Feedback is welcome.  It probably won't melt your machine
  148.   not a pool of liquid silicon, but then again...
  149.  
  150.      NOTE: This program is copyrighted, but may be used, shared, and copied
  151.   freely, as long as no charge is made for the program itself.  I don't want
  152.   any money for it (well, I could be persuaded....).
  153.  
  154.   John Simonson
  155.   Department of Psychology
  156.   University of Rochester
  157.   Rochester, NY  14627
  158.