home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / m / msh21.zip / GOODIES.ZIP / BERK.DOC next >
Text File  |  1992-03-29  |  167KB  |  4,953 lines

  1.  
  2.  
  3.  
  4.                              Table of Contents
  5.  
  6. Introduction
  7.  
  8. Calling the utilities
  9.  
  10. awk::::::: ::: ::: ::: :::: ::: ::: ::: ::: ::: string processing language
  11. basename :::::::: extract base part from pathname of a file or a directory
  12. cal::::::: ::: :::: ::: ::: ::: display the calendar for a month or a year
  13. cat::::::: ::: :::: ::: ::: ::: ::: ::: ::: :::: ::: ::: concatenate files
  14. cb ::::::::: ::: :::: ::: ::: ::: ::: ::: ::: :::: ::: ::: :: C beautifier
  15. comm::::::: ::: ::: ::: ::: ::: ::: ::: look for common lines in two files
  16. cmp::::::: ::: ::: ::: ::: :::: ::: ::: ::: ::: ::: file binary comparison
  17. cp::::::: :::: ::: ::: ::: ::: ::: ::: :::: ::: copy files and directories
  18. cut ::::::::: ::: :::: ::: ::: ::: :: cut out columns or fields from files
  19. df:::::: :::: ::: ::: ::: ::: ::: ::: :::: ::: :: statistics on disk usage
  20. diff:::::::: ::: ::: ::: ::: ::: ::: :::: ::: compare files or directories
  21. dtree::::::: ::: ::: ::: ::: ::: ::: display tree structure of directories
  22. ech:::::::: ::: ::: ::: ::: ::: ::: :::: ::: ::: ::: ::: ::: :::: ::: echo
  23. ed::::::: ::: ::: ::: ::: ::: :::: ::: ::: ::: ::: ::: ::: ::: line editor
  24. find:::::: find files with certain properties and execute commands on each
  25. grep:::::::: ::: ::: ::: ::: ::: ::: :::: ::: search for patterns in files
  26. ls::::::: ::: ::: ::: :::: ::: ::: ::: ::: ::: lists files and directories
  27. make::::::: ::: :::: ::: ::: ::: ::: ::: ::: :::: ::: ::: ::: update files
  28. more ::::::::: :::: ::: ::: ::: ::: ::: ::: :::: ::: :: text files browser
  29. mv::::::: ::: ::: ::: :::: ::: ::: ::: ::: ::: moves files and directories
  30. od::::::: ::: ::: ::: :::: ::: ::: ::: ::: ::: octal (or hexadecimal) dump
  31. paste:::::::: ::: ::: ::: ::: ::: :merge files as columns of a single file
  32. rederr ::::::::: ::: :::: ::: ::: ::: :: redirect error output of commands
  33. rm:::::: :::: ::: ::: ::: ::: ::: ::: :::: :: remove files and directories
  34. sed::::::: ::: :::: ::: ::: ::: ::: ::: ::: :::: ::: ::: ::: stream editor
  35. sort ::::::::: ::: :::: ::: ::: ::: ::: ::: ::: :::: ::: ::: :: sort files
  36. split::::::: ::: ::: :::: ::: ::: ::: ::: split a file into smaller pieces
  37. tail::::::: ::: ::: ::: :::: ::: ::: ::: ::: ::: display the end of a file
  38. tee::::::: ::: ::: ::: :::: ::: ::: ::: ::: pipe connection and derivation
  39. touch:::::: :::: ::: ::: ::: ::: ::: ::: :::: ::: :: update file timestamp
  40. tr ::::::::: ::: ::: ::: :::: ::: ::: ::: ::: :: translate stdin to stdout
  41. uniq ::::::::: ::: ::: :::: ::: ::: ::: :: weed out or find repeated lines
  42. wc:::::::: ::: ::: ::: ::: :::: ::: ::: ::: ::: ::: :count words and lines
  43. xstr::::::: ::: :::: ::: ::: ::: extract character strings from C programs
  44.  
  45. Appendix:  Regular Expressions
  46.  
  47.  
  48.     ?  Copyright OPENetwork and PMC 1989.  All rights reserved.
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. The Berkeley Utilities V1.0 -------------------------- Table of Contents [i]
  58.  
  59.  
  60.  
  61.     The  Berkeley  Utilities  are  a  set  of  UNIX1  like utilities  for  the
  62. MS-DOS2 operating system.   They have been developed by P.M.C. (a software
  63. company from Paris, France) for its internal use,  because there was  (and
  64. still is) no available commercial package covering the same needs.   It is
  65. not yet as complete a set of UNIX commands as can  be found in some  other
  66. packages (e.g.   MKS) but it contains some useful utilities you don't find
  67. elsewhere (e.g.  cb, xstr).  We hope as soon as possible to have a complete
  68. set (look at our update policy).  We will have an OS/23 version as soon as
  69. there is a demand for it.
  70.  
  71.     The particular advantages of our utilities come from our design goals:
  72.  
  73.  1- Since we had to rewrite for MS-DOS the UNIX utilities, we decided to do
  74.     them right:  you will find any useful option you ever had on  any UNIX
  75.     system, and often new options which make sense and increase the  power
  76.     of the package.  People who have been using our package, when going (or
  77.     coming back to) UNIX often wish our extra options would work there (we
  78.     are considering alleviating their suffering by porting our commands to
  79.     UNIX !).  If you are a UNIX user, look at our extra options on cp, mv,
  80.     ls and others; you will see what we mean!
  81.  2- We also decided to use the advantages of working  in MS-DOS when  they
  82.     exist, e.g.  the use of video attributes to make displays clearer.
  83.  3- Since we believe that using combinations of UNIX commands to do  small
  84.     (or big jobs) is a powerful way  to work,  which we wish  to teach  to
  85.     others,  we also are aiming our package to all  PC users,  and made  a
  86.     special effort to provide on-line help and tutorial information.   You
  87.     will learn a new way to work, and it will be an ever  useful knowledge
  88.     (at least until UNIX dies, which won't be tomorrow).
  89.  4- We  wanted  our  utilities  to  be self-contained,  and  able to  be  used
  90.     individually without going through any installation procedure.    Each
  91.     utility is self-contained without any extra  files needed,  and has  a
  92.     help screen (usually enough to get by, excepted for the more ambitious
  93.     utilities such as awk and make).
  94.  
  95.     At this stage, if you are new to UNIX, we recommend that you go through
  96. our User's Manual, and use our integrated help.  We recommend the following
  97. books to help you along:
  98.   - ``The UNIX programming environment'', Kernighan and Plauger.
  99.   - For  awk  ``The  AWK  programming  language'',   Aho,   Weinberger  and
  100.     Kernighan.
  101.     If you are a UNIX wizard look  in our  man pages,  try everything  and
  102. enjoy (man refers to the manual,  which in  UNIX is  available on-line  by
  103. running a program called man).
  104.  
  105.  
  106.  
  107.     Jean MICHEL
  108. ----------------------------
  109.   1  UNIX is a trademark of AT&T
  110.   2  MS-DOS is a trademark of Microsoft Corporation
  111.   3  OS/2 is a trademark of Microsoft Corporation
  112.  
  113.  
  114. [ii] Introduction ------------------------------ The Berkeley Utilities V1.0
  115.  
  116.  
  117.  
  118.  
  119.  
  120. Command line handling:
  121.  
  122.     All  The  Berkeley  Utilities  can  apply transformations  to the  command
  123. line,  doing  their  best  to  emulate  the  behavior  of shells  under  UNIX,
  124. insofar as MS-DOS allows it:
  125.  
  126.   o Arguments prefixed with `-' are options.   An option is defined by the
  127.     character following the `-' and may or may not take  a parameter.   As
  128.     in UNIX, the options are case sensitive, which means that the  command
  129.     ls -t has a different meaning than the command ls -T. When the  option
  130.     takes a parameter, the parameter may be mandatory, in which case it may
  131.     be separated from the option by spaces, or it may be optional, in which
  132.     case it must follow the option immediately.   An option standing alone
  133.     may  be  followed  by  (bundled  with) another  option without  separating
  134.     space  and  `-'  character,  e.g.,  if  - s and  - x  are options  without
  135.     parameters, those options may be bundled as:   -sx.   Some options are
  136.     ``boolean flags'' (that is,  it makes sense to turn  them on or  off).
  137.     These options can then usually be turned off  by giving them  followed
  138.     by  a  `-',  e.g.,  -s-x means  take  option x  but  turn off  s (this  is
  139.     especially useful in connection with an initial  command line ---  see
  140.     below).
  141.  
  142.   o Options -?, -H, and, in case it has no other significance, option  -h,
  143.     are taken to be a call  for help:   a message  describing the  utility
  144.     usage syntax is sent to standard output with a short explanation of the
  145.     semantics of the arguments and of the other options.
  146.  
  147.   o An option of ``--'' is taken to end the list  of options; any  further
  148.     arguments  beginning  with  `-'  will  not  be  interpreted  as  options.
  149.     Contrary  to  usual  unix  behaviour,  by  default  options  may  appear
  150.     anywhere  on  the  command  line  (they  do  not  have to  be  grouped  at
  151.     its beginning).   This behaviour may be changed by  giving the  option
  152.     `-!';  then the first non-option argument will end  the options  (this
  153.     is particularly useful in conjunction with setting an initial  command
  154.     line; see below).
  155.  
  156.   o ``-'' standing alone is not usually taken to be an option, but to be an
  157.     argument standing for standard input stdin (we adopt standard UNIX and
  158.     MS-DOS terminology:  a program takes its input from stdin (usually the
  159.     terminal, but it may be redirected with `<'), sends its normal  output
  160.     to  stdout  (which  can  be  redirected with  `>'),  and sends  its  error
  161.     output to stderr (which cannot be redirected under MS-DOS)).
  162.  
  163.   o Arguments starting with a ``$'' are taken to be environment variables,
  164.     and  a  variable  substitution  mechanism  is  applied:    e.g.,  if  the
  165.     autoexec.bat file included the assignment:
  166.       set INCLUDE=c:\include
  167.     ``c:\include'' will be substituted for ``$INCLUDE''.  If the  variable
  168.     is  immediately  followed  by  characters  allowed in  identifiers,  curly
  169.     brackets  must  be  used:    if  the  environment  variable  ``MAKEFLAGS''
  170.     has been assigned the value ``ei'',  ``eid'' will  be substituted  for
  171. The BerkeleyFUtilities V1.0 -------------------- Callingothedutilities [iii]
  172.  
  173.       - ${x-z} stands for the value of environment variable x if x has been
  174.         defined,  else  for  the  string  z.   E.g.,  by  anticipation on  the
  175.         following paragraph on command substitution, ${HOME-`cd`} stands for
  176.         the value of environment variable HOME if HOME has been defined, and
  177.         else for the name of the current directory.
  178.       - ${x=z} is like the previous case, but in addition if x had not been
  179.         defined, it is now assigned value z until the utility ends.
  180.       - ${x?z} stands for the value y of environment variable  x if x  has
  181.         been defined, else message z is sent to  standard output, and  the
  182.         utility aborts.
  183.       - ${x+z}  stands  for  z  if  x has  been defined,  else  for the  empty
  184.         string.
  185.  
  186.   o Another substitution mechanism is applied to  arguments surrounded  by
  187.     backquotes ```'', called command substitution.   First, the text inside
  188.     the  ```''s  is  executed  as  a  command,  then  its standard  output  is
  189.     inserted in the command line,  after substituting spaces for  imbedded
  190.     newlines, and after stripping trailing newlines.
  191.  
  192.   o Finally, an argument including a ``*'', a ``?''  or a ``['' is taken to
  193.     be a file specification pattern, and expansion is applied:   its place
  194.     is taken by the list of actual  files whose name  matches the  pattern
  195.     according to the following rules:
  196.       - The  star  ``*''  stands  for any  number (0  included) of  characters
  197.         except ``\'', ``/'', ``.''.
  198.       - The question mark ``?''   stands for exactly one character not  in
  199.         ``\'', ``/'', ``.''.
  200.       - One or more characters surrounded by ``[ ]'' stand for exactly one
  201.         of the surrounded characters.   If the character following ``['' is
  202.         ``!'', the form stands for exactly one character not in the set of
  203.         the characters between the ``!''  and the ``]''.  Inside the ``[]'',
  204.         after the possible initial ``!'', a sequence like a-p stands for the
  205.         set of characters whose ASCII code is between those of a and p.
  206.       - A ``.''  ending the pattern is ignored.
  207.       - ``/'' et ``\'' are both acceptable as delimiting directories in  a
  208.         path name.
  209.       - Finally,  the  sequences  ``//''  and  ``\\''  match  any  number  of
  210.         consecutive directory names in a pathname.
  211.     For example,
  212.       ?/[a-h]*.c
  213.     means all the files whose filename start with a letter between a and h,
  214.     which have an extension of c, and which are located in a one-character
  215.     subdirectory of the current directory.
  216.  
  217.       NB1: Those patterns are similar in some ways to regular expressions.
  218.            But there is no closure operator, ``?'' plays the part of ``.'',
  219.            ``*''  is  equivalent  to  ``[^.\]*'',  in  character  classes  the
  220.            complement operator is ``!'' instead of ``^''.
  221.       NB2: Divergences from UNIX file specification patterns:  under UNIX,
  222.            ``.'' has no special properties except as the first character of
  223.            a filename.  Under MS-DOS, a file or directory name may contain
  224.            at most one ``.'', and a  name without  a ``.'' designates  the
  225.  
  226.  
  227.  
  228. [iv] Calling the utilities --------------------- The Berkeley Utilities V1.0
  229.  
  230.            same file as the same name with the ``.''  appended.   Moreover
  231.            a  name  can  have  at  most  8  characters before  a ``.''  and  3
  232.            characters after it.
  233.       NB3: Divergences  from  MS-DOS:  a  name  with  less  than 8  characters
  234.            before  an  explicit  or  implicit  ``.''  is  not supposed  to  be
  235.            completed  to  8  characters  by  spaces.    Thus  the behavior  of
  236.            ``?''  differs  from  MS-DOS  expansion  where  it  sometimes  ends
  237.            up  standing  for  one  or  no  character.    On  the  other  hand,
  238.            patterns  where  an  initial  ``*''  is  followed  by  non-special
  239.            characters are handled as you would expect (as in UNIX), whereas
  240.            MS-DOS  sees  no  difference  from  ``*''  alone.    For  instance,
  241.            The Berkeley Utilities see *A.* as all the files whose filename
  242.            ends with an A, while MS-DOS does not distinguish *A.* from *.*.
  243.       NB4: Be aware that patterns can only stand for existing files.  Since
  244.            the syntax of cp and  mv are  different from that  of copy  and
  245.            rename, commands such as
  246.              copy *.bin *.obj
  247.            have no equivalent with The Berkeley Utilities.   Nevertheless,
  248.            an equivalent result may be obtained by  a combination of  some
  249.            command repetition mechanism (such as the  MS-DOS for  command)
  250.            and the basename utility:
  251.              for %i in (*.bin) do cp %i `basename %i .bin=.com`
  252.            (note that %i must be replaced by %%i in a batch file).
  253.  
  254.  
  255. Installation and Video Attributes:
  256.     The installation is an easy procedure:   just copy the files from  the
  257. distribution disks to a subdirectory on  your hard disk,  then place  that
  258. directory on the path before the one which contains MS-DOS.
  259.     The  Berkeley  Utilities  will  work  independently  of  each  other  and
  260. without any installation.   They are easily configurable with the help  of
  261. the supplied program opts.exe.   This program sets an initial command line
  262. for any utility.  For instance
  263.  
  264.         opts rm "-i -r"
  265.  
  266. would set the initial command line of  rm to  -i -r,  which means that  on
  267. any future call to rm, the options -i -r will  be prepended to the  actual
  268. command line.   This could be used to give default arguments, in  addition
  269. to setting default options.   The mechanism is such that  the part of  the
  270. command line thus given does not count in the DOS limit of  128 characters
  271. for the command line and may be arbitrarily long.
  272.     The  Berkeley  Utilities  use  different  video  attributes  in  order  to
  273. highlight the key parts of their output as long  as ansi.sys is  resident;
  274. to make ansi.sys resident, you must include in your config.sys file a line
  275. like
  276.  
  277.   device = \dos\ansi.sys
  278.  
  279.     You should actually use the less buggy  shareware product  NNANSIN.SYS
  280. which  is  included  in  the  demo  disk and  available on  our  BBS. Most  of
  281. The Berkeley Utilities use 3 attributes, but some (more, for instance) use
  282. many more.   Those attributes may be selected  globally for all  utilities
  283.  
  284.  
  285. The Berkeley Utilities V1.0 ---------------------- Calling the utilities [v]
  286.  
  287. by assigning values to the environment variable ``VATTR'' in the following
  288. way:
  289.   set VATTR=attribute0-attribute1-attribute2-...attributen
  290. attributei  being  the  middle  part  of  an  ANSI  `Set  Graphic  Rendition'
  291. Escape-sequence, e.g., a sequence formed thus:
  292.   <Esc>[p1;p2;...pkm
  293. stripped of initial ``<Esc>['' and of final ``m''.   The parameters pi are
  294. as described in MS-DOS reference manuals, for instance:
  295.   set VATTR=44;36;1-44;33;1-44;35;1-40;36;1-40;31;1-40;37;1-42;30-42;33;1
  296. selects 8 attributes on a color card:
  297. bright cyan on blue, bright yellow on blue, bright magenta on blue, bright
  298. cyan on black, bright red on black, white on black, black on green, bright
  299. yellow on green.
  300.  
  301.     The following example:
  302.   set VATTR=0-1-4-7;1-7-7;4
  303. selects 6 attributes for a monochrome configuration:
  304. normal on black,  highlighted on black,  underlined black,  grey on white,
  305. black on white, inverse underlined.  The attributes can be set for a single
  306. utility using the `-@' option which takes as  argument a string  following
  307. the same syntax as VATTR. The usual way  to proceed would  be to set  this
  308. option in an initial command line via opts.   The command `opts -e' may be
  309. used to edit interactively the initial  command line and  has support  for
  310. selecting attributes from a menu.
  311.     When  the  utilities  output  is  redirected  to  a file,  attributes  are
  312. normally not output.  Nevertheless, if the option `-&' is given, output to
  313. a file and to the terminal is  treated the same  way.   This is  specially
  314. useful if the output is piped to a browser which can emulate ansi.sys, such
  315. as more.  For instance, to look at leisure at strings found, type
  316.  
  317.       grep -& thing *.c |more
  318.  
  319. The method of assigning the value ANSI to  the environment variable  FATTR
  320. which was in the version 1 of The Berkeley Utilities is now  obsolete (the
  321. above method is better since it can be controlled on each use).
  322.     Sometimes  our  detection  logic  fails  for  some strange  ANSI  drivers.
  323. There is a way to tell the utilities  not to use  ANSI attributes even  if
  324. they detect ANSI.SYS: just do ``set VATTR=NO''.
  325.  
  326.  
  327. Command spawning from The Berkeley Utilities :
  328.  
  329.     In many cases, (command substitution, make methods, ``!''  commands of
  330. ed and more, -exec predicate of find,  etc...).   utilities have to  spawn
  331. some other command.   The normal way to do  this is  to spawn a  subshell,
  332. where under MS-DOS the shell to be spawned  is given by  the value of  the
  333. environment variable ``COMSPEC''. Actually, if it is possible, the commands
  334. are spawned directly without a subshell intervening.   This is useful  for
  335. the utilities which need to know the exit status of spawned commands (make,
  336. find,  ...),  since the standard MS-DOS shell (command.com) does not  make
  337. this information available.   A command can be spawned  directly if it  is
  338. not an internal MS-DOS command and does not use pipes (|).   Otherwise the
  339. command  is  spawned  via  a  subshell and  will always  be  supposed to  have
  340. succeeded.
  341.  
  342. [vi] Calling the utilities --------------------- The Berkeley Utilities V1.0
  343.  
  344.                                                   String-processing language
  345.  
  346.  
  347. Synopsis:                   awk [-Fc] -f program [files]
  348.  
  349. or                           awk [-Fc] "program" [files]
  350.  
  351.  
  352. Description:
  353.  
  354.     If you are not already familiar with awk,  it is strongly  recommended
  355. that you read the excellent 1988 Addison-Wesley book "The AWK  Programming
  356. Language",  by  Aho,  Kernighan  and  Weinberger  who  gave the  language  its
  357. ``awk''ward name.  The following is not intended to serve as a tutorial for
  358. the language.
  359.  
  360.  
  361.     The awk program to execute is in the file specified as argument to the
  362. -f option, or is the first argument on the command line if there is  no -f
  363. option.   The file arguments processed by the program are considered as  a
  364. sequence of records separated by record-separator characters, each  record
  365. itself being a sequence of fields separated by field-separator characters.
  366. By default, the record-separator is the newline, so records are consecutive
  367. lines of the file, and the field-separator is the  space.   These defaults
  368. may be changed as will be seen below.  If the field-separator is the space,
  369. as a special convention the <Tab> and the newline are also field-separators
  370. (this is specific to the space).  An ``awk'' program consists in a sequence
  371. of pairs ``condition { actions }''.  For each record in each file argument
  372. which  matches  the  condition  the  corresponding actions  are executed.    A
  373. missing condition is considered to match every record, and a missing action
  374. is equivalent to the action {print} which prints the current record.
  375.  
  376.  
  377.     The actions are written in a language whose syntax is similar to  that
  378. of  the  language  C,  but  whose semantics  are quite  different:   Variables
  379. can  hold  numeric  or  string  values,  or  be  arrays,  but  there  are  no
  380. declarations.  A variable may indifferently hold numeric or string values;
  381. the  conversion  between  these  is  automatically  performed in  any  context
  382. where it is necessary; numeric values are floating-point numbers.   On the
  383. other hand,  the first occurence of a variable  decides if it  will be  an
  384. array  or  scalar  (if  it  is indexed  or not  in this  first occurence)  and
  385. then its nature (scalar or array) will  be the  same for the  rest of  the
  386. program.   Array indices may be any scalar value, which provides a kind of
  387. associative memory.   Operators are those of the C language when they make
  388. sense.   Structured programming constructs are available as in C by  using
  389. the keywords for, while, if and else.   A variant of for is provided which
  390. loops over an associative array.   The  language contains  a few  built-in
  391. variables and functions.  The conditions are built using boolean operators
  392. from relational expressions and regular expressions (look in the  Appendix
  393. for a definition of regular expressions; the regular expressions currently
  394. do not have the alternation operator,  they will  be extended  in a  later
  395. version).  In addition a condition may be a pair of conditions as described
  396. above, separated by commas.  Such a condition holds between the first line
  397. satisfying  the  first  condition  and  the next  line  satisfying the  second
  398. condition, and again between such pairs of lines until the end of the file.
  399. The Berkeley Utilities V1.0 ---------------------------------------- awk [1]
  400.  
  401. Formal Grammar of awk:
  402.     (In  the  documentation  which  follows,  ``iff'' is  an abbreviation  for
  403. ``if and only if'').
  404.  
  405. <program> :=  <begin> <body> <end>
  406.  
  407. <begin> :=  BEGIN { <actions> }
  408.                    BEGIN is a special condition which declares <actions> to
  409.                    perform before starting to read the first file argument.
  410.         |  nothing
  411.                    i.e.  no initial <actions>.
  412.  
  413. <body> := <body> <action-condition>
  414.        |  <body> <action-condition> <terminator>
  415.        |  nothing
  416.                    The   <body>   of   the   program   is   a   sequence   of
  417.                    <action-condition>s,  separated  by  ``;''  or  newlines.
  418.                    The  <body> is  executed  by  applying  successively  each
  419.                    <action-condition> to each records of each file.
  420.  
  421. <end> :=  END { <actions> }
  422.                    END is a special condition which declares the <actions>
  423.                    to perform after processing the last record of the last
  424.                    file.
  425.       |  nothing
  426.                    i.e.  no final <actions>.
  427.  
  428. <action-condition> := <pattern>
  429.                    Print each record which matches the <pattern>.
  430.                    |  <pattern> { <block> }
  431.                    For each record matching the <pattern>, execute actions
  432.                    in <block>.
  433.                    |  <pattern> , <pattern>
  434.                    Wait  for  a  record  matching  the first  <pattern>,  then
  435.                    print  each  record  until  the  next record  matching  the
  436.                    second <pattern>, and so on.
  437.  
  438.                    |  <pattern> , <pattern> { <block> }
  439.                    Wait  for  a  record  matching  the first  <pattern>,  then
  440.                    execute the <block> of actions for each record until the
  441.                    next record matching the second <pattern>, and so on.
  442.                    |  { <block> }
  443.  
  444.                    For each record, execute actions in <block>.
  445.  
  446. <pattern> := <regular-expression>
  447.                    A  record  matches  the  <pattern>  iff  it  matches  the
  448.                    <regular-expression>.
  449.           |  <match>
  450.           |  <relational-expression>
  451.  
  452.           |  <composed-pattern>
  453.  
  454.  
  455.  
  456. [2] awk ---------------------------------------- The Berkeley Utilities V1.0
  457.  
  458. <composed-pattern> := <pattern> || <pattern>
  459.                    Alternation:  a record matches the <composed-pattern> if
  460.                    it matches one of the two <pattern>s.
  461.                    |  <pattern> && <pattern>
  462.                    Conjunction:  a record matches the <composed-pattern> if
  463.                    it matches both <pattern>s.
  464.                    |  !  <pattern>
  465.                    Negation:  a record matches the <composed-pattern> if it
  466.                    does not match the <pattern>.
  467.                    |  ( <composed-pattern> )
  468.                    Grouping.
  469.  
  470. <block> := <block> <statement>
  471.         |  nothing
  472.  
  473.                    <block>  is  a  sequence  of  <statement>s,  executed  by
  474.                    successively  executing  each  <statement>.     A  break,
  475.                    continue,  next  or  exit  statement  may  stop  execution
  476.                    before the end of the <block>.
  477.  
  478. <statement> := <simple-statement> <terminator>
  479.             |  if ( <condition> ) <statement> else <statement>
  480.                    If  the  <condition>  is  true  the  first  <statement>  is
  481.                    executed, else the second one.
  482.             |  if ( <condition> ) <statement>
  483.  
  484.                    The <statement> is executed if the <condition> is true.
  485.             |  while ( <condition> ) <statement>
  486.                    While  the  <condition> evaluates  to  true,  execute  the
  487.                    <statement>.
  488.  
  489.             |  for ( <variable> in <variable> ) <statement>
  490.                    The second <variable> must be an array, and then for each
  491.                    element of that array the <statement> is executed, with
  492.                    the first <variable> set to the value of that element.
  493.             |  for ( <simple-statement> ; <condition> ; <simple-statement> ) <statement>
  494.  
  495.                    Execute the first <simple-statement>,  then loop on the
  496.                    sequence:  evaluate the <condition>, if true execute the
  497.                    <statement>, then execute the second <simple-statement>.
  498.             |  for ( <simple-statement> ;; <simple-statement> ) <statement>
  499.                    Identical  to  the  above  form  except  the  condition  is
  500.                    always true.   This loop can be exited only by a break,
  501.                    next, or exit.
  502.  
  503.             |  break <terminator>
  504.                    Get out of the current loop (the innermost one if several
  505.                    loops are embedded).
  506.             |  continue <terminator>
  507.  
  508.                    Go  directly  to  the  next iteration  through the  current
  509.                    loop.
  510.  
  511.  
  512.  
  513. The Berkeley Utilities V1.0 ---------------------------------------- awk [3]
  514.  
  515.             |  { <block> }
  516.                    Execute  the  <block> (see  the  definition  of  a  <block>
  517.                    above).
  518.  
  519.             |  next <terminator>
  520.                    The  next  statement  causes  the  current  record  to  be
  521.                    abandoned, the next record to be read and execution  to
  522.                    resume at the beginning of the program body.
  523.  
  524.             |  exit <expression> <terminator>
  525.  
  526.             |  exit <terminator>
  527.                    The exit statement is equivalent to the end of the last
  528.                    file.  If an expression follows exit, it is evaluated and
  529.                    its value is used as the return code from awk.
  530.  
  531. <condition> := <expression>
  532.                    As in the C language, the <condition>  is true iff  the
  533.                    <expression> evaluates to a non-zero value.
  534.  
  535.             |  <relational-expression>
  536.  
  537.             |  <match>
  538.  
  539.             |  <composed-condition>
  540.  
  541. <composed-condition> := <condition> || <condition>
  542.                      |  <condition> && <condition>
  543.  
  544.                      |  !  <condition>
  545.  
  546.                      |  ( <composed-condition> )
  547.                    The syntax of <condition>s is very similar to that of the
  548.                    <pattern>s.   Note that, in contrast to C, an expression
  549.                    is  meaningful  as  a  condition but  the  converse is  not
  550.                    true.
  551.  
  552. <simple-statement> := print <list> <redirection> <expression>
  553.                    The items of the <list> as well as the final <expression>
  554.                    are  evaluated  as  character  strings;  then  the  items
  555.                    are  printed,  separated  by  the  output  field-separator
  556.                    (variable  OFS)  to  the  file  whose  name  is  the  value
  557.                    of  the  final  <expression>  (this  file  is  created  if
  558.                    non-existent).  If the file did exist, the text replaces
  559.                    its contents, except that if <redirection> is ``>>'', the
  560.                    text is appended to the file.
  561.  
  562.                    |  print <list>
  563.                    Same as above, the output file being stdout.
  564.                    |  print <redirection> <expression>
  565.  
  566.                    |  print
  567.                    If print has no arguments,  $0 (the current record)  is
  568.                    printed.
  569.  
  570. [4] awk ---------------------------------------->ThexBerkeley>Utilities V1.0
  571.  
  572.                    |  printf <list>
  573.                    As print, but the first item in the list is interpreted
  574.                    as a character string to yield a format, which is used to
  575.                    print the other items, with the same conventions as  in
  576.                    the C printf function.
  577.                    |  <expression>
  578.  
  579. <expression> := <expression> <term>
  580.                    <expression>  and  <term>  are  evaluated  to  character
  581.                    strings and catenated.
  582.              |  <term>
  583.              |  <value> = <term>
  584.              |  <value> += <term>
  585.  
  586.              |  <value> -= <term>
  587.              |  <value> *= <term>
  588.              |  <value> /= <term>
  589.  
  590.              |  <value> %= <term>
  591.                    Assignment operators, which have the same meaning as the
  592.                    corresponding operators in the C language.
  593.  
  594. <term> := <value>
  595.        |  ( <expression> )
  596.  
  597.        |  <term> + <term>
  598.        |  <term> - <term>
  599.  
  600.        |  <term> * <term>
  601.        |  <term> / <term>
  602.  
  603.        |  <term> % <term>
  604.        |  + <term>
  605.  
  606.        |  - <term>
  607.                    Dyadic and monadic operators, which have the same meaning
  608.                    and syntax as in C.
  609.        |  ++ <value>
  610.  
  611.        |  -- <value>
  612.        |  <value> ++
  613.  
  614.        |  <value> --
  615.                    Pre and post-decrementation and incrementation, as in C.
  616.        |  <function> ( <expression> )
  617.  
  618.        |  <function> ()
  619.        |  <function>
  620.  
  621.                    Where  <function> is  one  of  the  intrinsic functions  of
  622.                    awk(see below the list of these functions).  If there is
  623.                    no argument, by default $0 (the current record) is used.
  624.  
  625.  
  626.  
  627. The Berkeley Utilities V1.0 ---------------------------------------- awk [5]
  628.  
  629.        |  getline
  630.                    getline reads the next record and returns it ($0) as its
  631.                    value, without breaking the program flow as next does.
  632.        |  sprintf <list>
  633.                    The first item in <list> is taken to be a format string.
  634.                    Similar to the sprintf of the standard C library.
  635.        |  substr ( <expression> , <expression> , <expression> )
  636.                    Returns   the   sub-string   of   the  first   <expression>
  637.                    which  starts  at  the  position  specified by  the  second
  638.                    <expression>, and whose length is at most the value  of
  639.                    the third expression.
  640.        |  substr ( <expression> , <expression> )
  641.                    Returns the terminal substring of the first <expression>
  642.                    which  starts  at  the  position  specified by  the  second
  643.                    <expression>.
  644.        |  split ( <expression> , <variable> , <expression> )
  645.                    Sets  <variable>  to  an  array  whose  elements  are  the
  646.                    substrings  obtained  by  splitting  the  first  string
  647.                    <expression> at places where occurs the separator which
  648.                    is  specified  by  the  first  character  of  the  second
  649.                    string <expression>, and returns as result the number of
  650.                    elements of that array.
  651.        |  split ( <expression> , <variable> )
  652.  
  653.                    Like the previous form,  but using as separator  field-
  654.                    separator  character  specified  by  the built-in  variable
  655.                    FS.
  656.        |  index ( <expression> , <expression> )
  657.                    returns an integer, the position of the first occurence
  658.                    of the second string <expression> as a substring of the
  659.                    first one; returns 0 if there is no occurence.
  660.  
  661. <value> := <variable>
  662.         |  <variable> [ <expression> ]
  663.                    <variable> must be an array, or must be mentioned  here
  664.                    for  the  first  time.    <expression> must  evaluate to  a
  665.                    scalar value.
  666.  
  667.         |  <field>
  668.         |  number
  669.                    A number is a floating-point number written as a sequence
  670.                    of digits, with an optional decimal point and exponent.
  671.         |  string
  672.  
  673.                    A  string  constant  is  a sequence  of characters  between
  674.                    double quotes `"'.   The ``\'' character may be used to
  675.                    quote the next character, allowing to specify characters
  676.                    impossible to put in the string otherwise:
  677.                   \\: A \.
  678.                   \": A double quote ".
  679.                   \n: A newline.
  680.                   \t: A <Tab>.
  681.  
  682.  
  683.  
  684. [6] awk ---------------------------------------- The Berkeley Utilities V1.0
  685.  
  686. <field> := $ <expression>
  687.                    <expression> must  evaluate  to  a  non-negative  integral
  688.                    value.   $0 is the current record, and cannot occur  on
  689.                    the left of an assignment operator.   $n where  n !=  0
  690.                    represents the nth field, and can be assigned to as any
  691.                    other.
  692.  
  693. <function> := length
  694.                    The function length gives back the length of its argument
  695.                    ($0 by default) interpreted as a character string.
  696.  
  697.            |  log
  698.                    logarithm function.
  699.  
  700.            |  int
  701.                    floor function.
  702.  
  703.            |  exp
  704.                    exponential function.
  705.  
  706.            |  sqrt
  707.                    square root function.
  708.                    These functions interpret their argument ($0 by default)
  709.                    as numbers, and return what their name implies.
  710.  
  711. <variable> := NF
  712.                    The variable NF holds the number of fields of the current
  713.                    record.
  714.  
  715.            |  NR
  716.                    NR holds the ordinal number of the currently  processed
  717.                    record.
  718.  
  719.            |  FS
  720.                    FS  holds  the  field-separator  character (this  character
  721.                    is  taken  from  the  first character  of the  value of  FS
  722.                    interpreted as a string).   By default this character is
  723.                    the space, unless the option -F has been given.
  724.  
  725.            |  RS
  726.                    RS holds the record-separator character, which by default
  727.                    is  the  newline.    If  ``RS''  is  an empty  string,  the
  728.                    records will be separated by an empty line.
  729.  
  730.            |  OFS
  731.                    OFS holds the output field-separator character which, by
  732.                    default, is the space.
  733.  
  734.            |  ORS
  735.                    ORS holds the output record-separator character which, by
  736.                    default, is the newline.
  737.  
  738.            |  OFMT
  739.                    OFMT holds the default output format for numbers which,
  740.                    by default, is ``%.6g''.
  741. The Berkeley Utilities V1.0 ---------------------------------------- awk [7]
  742.  
  743.            |  FILENAME
  744.                    Holds the current filename.
  745.  
  746.            |  identifier
  747.                    An identifier is a sequence of letters, digits and ``_'',
  748.                    not beginning with a digit,  and not one  of the  names
  749.                    of  built-in  functions  and  variables.    Variables  are
  750.                    initialized to the empty string (i.e.  this is the value
  751.                    they have when used before being assigned to).
  752.  
  753. <regular-expression> := /re/
  754.                    Look  at  the  Appendix  for  the  syntax  of   regular
  755.                    expressions.
  756.  
  757. <match> := ( <match> )
  758.  
  759.         |  <expression> ~ <regular-expression>
  760.                    True iff <expression> matches <regular-expression>.
  761.  
  762.         |  <expression> !~ <regular-expression>
  763.                    True iff <expression> does not match <regular-expression>.-
  764.  
  765. <relational-expression> := <expression> == <expression>
  766.  
  767.                         |  <expression> != <expression>
  768.  
  769.                         |  <expression> >= <expression>
  770.  
  771.                         |  <expression> <= <expression>
  772.  
  773.                         |  <expression> > <expression>
  774.  
  775.                         |  <expression> < <expression>
  776.                         |  ( <relational-expression> )
  777.                    These  operators  have  the  same  meaning  as  in  the  C
  778.                    language.
  779.  
  780. <list> := ( <list> )
  781.  
  782.        |  <list> , <expression>
  783.  
  784.        |  <expression>
  785.  
  786. <redirection> :=  >
  787.               |  >>
  788.  
  789. <terminator> := ;
  790.  
  791.              |  newline
  792.  
  793.  
  794.     Newlines are not irrelevant as in C, since  they can  be used to  mark
  795. the  end  of  a  statement,  but they  are allowed  after if  (  ... ),  else,
  796. while ( ... ), and for ( ... ) .  Outside of character string constants or
  797. regular expressions, ``#'' signals the beginning of a comment, and the rest
  798. [8]tawkl---------------------------------------- The Berkeley Utilities V1.0
  799.  
  800. Option:
  801.  
  802.     The option -Fc  allows to change the default field-separator character
  803. to c.  If c is ``t'', it is understood as <Tab>.
  804.  
  805.  
  806.  
  807. Examples:
  808.  
  809. 1-- To count the number of lines of a file (same as wc -l file):
  810.  
  811.         awk "END{print NR}" file
  812.  
  813. 2-- To print a file, each line prefixed with its line number:
  814.  
  815.         awk "{print NR, "'$'"0}" file
  816.  
  817. or more reasonably, place the following line in a separate awk program:
  818.  
  819.  
  820.         {print NR, $0}
  821.  
  822. 3-- To print all lines of a file which exceed 79 characters:
  823.  
  824.  
  825.         awk "length > 79" file
  826.  
  827. 4-- To print all lines of a file containing december in French  or English
  828. (equivalent to ``grep \<[Dd][ee]c file''):
  829.  
  830.         awk "/\<[Dd][ee]c/" file
  831.  
  832. 5-- To find files in the current directory dated between 21th and  31th of
  833. december:
  834.  
  835.  
  836.     ls -T | awk "$1 ~ /Dec/ && $2>20{print $4}"
  837.  
  838. Let us follow how example 5 works.  First, it is equivalent to running awk
  839. on the output of ls -T1 (the option -1 of ls is implied in case of a pipe).
  840. A typical line of that file looks like:
  841.  
  842.     Dec 25 21:07 c:\bin\awk.exe
  843.  
  844.  
  845. So when processing the file, $1 is the month (here ``Dec''), $2 is the day
  846. (here ``25''), $3 is the hour (or the  year for files  more than 6  months
  847. old),  (here  ``21:07''),  $4  is  the  filename  (here  ``c:\bin\awk.exe'').
  848. ``$1 ~ /Dec/'' selects lines for december, and ``$2 > 20'' selects amongst
  849. those the ones whose day is greater than 20 (the operator ``>'' forces the
  850. second field to be interpreted as a number).  The action for selected lines
  851. is to print the fourth field, i.e.  the filename.
  852.  
  853.  
  854.  
  855. The Berkeley Utilities V1.0 ---------------------------------------- awk [9]
  856.  
  857. 6-- To count the number of files dated from each month (this  example uses
  858. an associative array):
  859.  
  860.     ls -T | awk -f count
  861.  
  862.     where count contains
  863.  
  864.       $1~/Jan/{n["January"]++}
  865.       $1~/Feb/{n["February"]++}
  866.       $1~/Mar/{n["March"]++}
  867.       $1~/Apr/{n["April"]++}
  868.       $1~/May/{n["May"]++}
  869.       $1~/Jun/{n["June"]++}
  870.       $1~/Jul/{n["July"]++}
  871.       $1~/Aug/{n["August"]++}
  872.       $1~/Sep/{n["September"]++}
  873.       $1~/Oct/{n["October"]++}
  874.       $1~/Nov/{n["November"]++}
  875.       $1~/Dec/{n["December"]++}
  876.       END{ for (m in n)
  877.            { if (n[m] > 1) NUM="s"
  878.              else NUM=""
  879.              print m ":",n[m],"file" NUM
  880.            }
  881.          }
  882.  
  883.  
  884.  
  885. Error Messages:
  886.  
  887. ``can't open `xxx'''
  888.     The program file, or an argument file, or a redirection file could not
  889. be opened.
  890. ``error in program''
  891. ``syntax error''
  892. ``lexical error''
  893.     Errors found in the awk program.
  894. ``xxx is not an array''
  895.     The variable after ``in'' in the 2nd form of a ``for'' loop is  not an
  896. array.
  897. ``can't set $0''
  898.     $0 has occured on the left of an (= += -= *= /= %=).
  899. ``funny variable xxx''
  900. ``illegal arithmetic operator''
  901. ``illegal assignment operator''
  902. ``illegal boolean operator''
  903. ``illegal function type''
  904. ``illegal jump type''
  905. ``illegal relational operator''
  906. ``illegal statement''
  907. ``illegal transformation to statement''
  908. ``illegal reference to array xxx''
  909.     An array as been referenced in a context where  a normal variable  was
  910. expected.
  911.  
  912. [10] awk --------------------------------------- The Berkeley Utilities V1.0
  913.  
  914. ``newline in string''
  915.     A string constant started with ``"'' has not been closed before the end
  916. of the line.
  917. ``newline in regular expression''
  918.     A regular expression started with ``/'' has not been closed before the
  919. end of the line.
  920. ``regular expression: missing `]'''
  921.     A character class opened with ``['' in  a regular  expression has  not
  922. been closed before the end of the line.
  923. ``not enough arguments in printf(xxx)''
  924.     printf or sprintf does not have the number of argument corresponding to
  925. the format.
  926. ``trying to access field n''
  927.     The expression following a ``$'' has a value which does not correspond
  928. to the number of a field of the current record.
  929. ``unexpected break, continue or next''
  930.     A break, continue, or next has been found at the topmost program level.
  931. ``too many output files n''
  932.     The  number  of  files  to which  output  may be  redirected is  currently
  933. limited to 10.
  934. ``out of memory''
  935. ``format item xxx... too long''
  936. ``record `xxx' has too many fields''
  937. ``record `xxx' too long''
  938. ``string xxx... too long to print''
  939. ``string too long''
  940. ``yacc stack overflow''
  941.     Various resources have been exhausted.
  942.  
  943.  
  944. Portability:
  945.  
  946.     New  features  of  awk  introduced  in  UNIX  version  V.3  are  not  yet
  947. implemented.
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969. The Berkeley Utilities V1.0 --------------------------------------- awk [11]
  970.  
  971.                                                 give base part of a pathname
  972.  
  973.  
  974. Synopsis:                           basename file
  975.  
  976. or                         basename file [... file] suffix
  977.  
  978.     Extracts the `filename' part from a full pathname.
  979.  
  980.  
  981. Description:
  982.  
  983.     In the first form,  basename strips from a pathname  logical unit  and
  984. directory  specifications.    In  the  second  form  basename  performs  this
  985. operation on all its arguments excepted the last which is interpreted as a
  986. suffix, and stripped from filename arguments which end with  it.   If this
  987. suffix has the form s1=s2,  all arguments ending  with s1  will have  this
  988. final s1 replaced by s2.
  989.  
  990.  
  991. Examples:
  992.  
  993.  
  994.  
  995.     C:>basename c:\bin\abc.exe
  996.     abc.exe
  997.     C:>basename c:\bin\abc.exe c:\bin\other.bak .exe
  998.     abc
  999.     other.bak
  1000.     C:>basename c:\bin\abc.exe c:\bin\other.bak .exe=.c
  1001.     abc.c
  1002.     other.bak.c
  1003.  
  1004.     To move to directory target all C source files such that there  exists
  1005. an executable with the same name:
  1006.  
  1007.     mv `basename *.exe .exe=.c` \target
  1008.  
  1009.  
  1010. Notes:
  1011.  
  1012.     basename  is  particularly  useful  in  conjunction  with  the  ``command
  1013. substitution''  performed  by  The  Berkeley  Utilities.    For  instance,  to
  1014. rename all files ending in .bin to  .com you  may use the  for command  of
  1015. MS-DOS as follows:
  1016.  
  1017.     for %i in (*.bin) do mv %i `basename %i .bin=.com`
  1018.  
  1019.  
  1020. See Also:
  1021.     find.
  1022.  
  1023.  
  1024.  
  1025.  
  1026. The Berkeley Utilities V1.0 ----------------------------------- basename [1]
  1027.  
  1028.                                   Display the calendar for a month or a year
  1029.  
  1030.  
  1031. Synopsis:                 cal [[month number] year number]
  1032.  
  1033.     Prints the calendar for a given month of a given year, or if the month
  1034. is omitted, for all months of a given  year;  if given with no  arguments,
  1035. gives the calendar of current month.
  1036.     Year may be between 1 and 9999; month must be between 1 and 12.
  1037.  
  1038.  
  1039. Notes:
  1040.  
  1041.     To learn something about the history of England, try cal 9 1752.
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083. The Berkeley Utilities V1.0 ---------------------------------------- cal [1]
  1084.  
  1085.                                                            concatenate files
  1086.  
  1087.  
  1088. Synopsis:                        cat file [... file]
  1089.  
  1090.  
  1091. Description:
  1092.  
  1093.     cat writes the concatenation of all the argument  files one after  the
  1094. other on stdout.   If no argument has been given, or for each occurence of
  1095. the argument ``-'', cat takes its input from stdin.
  1096.  
  1097.  
  1098. Examples:
  1099.  
  1100.     C:>cat abc
  1101.     is equivalent to
  1102.     C:>type abc
  1103.  
  1104.  
  1105.  
  1106.     C:>cat - autoexec.bat - >autoexec.new
  1107.     set include=c:\msc\include;c:\msc\include\sys
  1108.     set lib=c:\msc\lib
  1109.     ^Z
  1110.     set temp=c:\tmp
  1111.     ^Z
  1112.     C:>mv autoexec.new autoexec.bat
  1113.  
  1114. This is a way to add two lines to the beginning and one line to the end of
  1115. a text file without using an editor!
  1116. ^Z  represents  <Control-Z> which  informs  MS-DOS  that  an end  of file  was
  1117. entered from the console.
  1118.  
  1119.  
  1120. Bugs:
  1121.  
  1122.     Since the same buffer is used for input and output, if one of the files
  1123. being concatenated is also used as stdout, the contents of the file will be
  1124. destroyed.  In order to append file2 at the end of file1, type:
  1125.     cat file2 >> file1
  1126.  
  1127.  
  1128. See Also:
  1129.  
  1130.     cp, mv, more.
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140. The Berkeley Utilities V1.0 ---------------------------------------- cat [1]
  1141.  
  1142.                                                                 C beautifier
  1143.  
  1144.  
  1145.  
  1146.  
  1147. Synopsis:             cb [options] [input file [output file] ]
  1148.  
  1149.     cb takes as input a C source file,  and rewrites  it according to  the
  1150. options specified on the command line.
  1151.  
  1152.  
  1153.  
  1154. Description:
  1155.  
  1156.     By default, cb works on stdin and stdout.   cb  beautifies a C  source
  1157. file according to your programming style, organizing especially the output
  1158. of blocks.   Preprocessor commands and declarations outside of a  function
  1159. are not changed.
  1160.  
  1161.  
  1162.  
  1163. Options:
  1164.  
  1165.     The following options are available on the command line:
  1166.  
  1167.     -in    n is an integer, value of the indentation used after  keywords.
  1168.            By default, 2.
  1169.  
  1170.     -c     Same level of indentation for a closing  curly bracket and  its
  1171.            corresponding keyword.  By default, the closing curly bracket is
  1172.            on the same level as the opening one.
  1173.  
  1174.     -s     The  statement  immediately  following  a  keyword will  appear  on
  1175.            the same line.   By default, it appears on the following  line,
  1176.            beginning at the next level of indentation.
  1177.  
  1178.     -o     The  opening  curly  bracket  appears  on  the  same  line  as  its
  1179.            corresponding keyword.  By default, it appears on the next line.
  1180.  
  1181.     -O     The opening curly bracket is on the line following the keyword,
  1182.            beginning  at  the  next  level of  indentation.    By default,  it
  1183.            keeps the same level as the keyword.
  1184.  
  1185.     -n     An else or a while immediately following a closing curly bracket
  1186.            appears  on  the  same  line.    By  default, every  closing  curly
  1187.            bracket is followed by a newline.
  1188.  
  1189.     -r     The first statement inside of a block appears on the same  line
  1190.            as the opening curly bracket.
  1191.  
  1192.     -R     The statements inside of a block appear  on the  same level  of
  1193.            indentation  as  the  opening  curly  bracket.   By  default,  they
  1194.            begin at the next level.
  1195.  
  1196.  
  1197. The Berkeley Utilities V1.0 ----------------------------------------- cb [1]
  1198.  
  1199. Examples:
  1200.  
  1201. Let us have a look at the output of 3 cb options working on the same input
  1202. file.
  1203.  
  1204.   C:>cat fopenp.c
  1205.   FILE *fopenp (path, fn, fnb, mode)
  1206.   register char *path;char *fn, *fnb, *mode;
  1207.   {    ...
  1208.       if  (*fn == '\\') if ( fd = fopen(fn, mode))
  1209.        { strcpy(fnb, fn);return (fd);}
  1210.       else return(NULL);
  1211.       do { while  ( *path != ';')*dst++ = *path++;
  1212.       if  (dst != fnb) *dst++ = '\\';
  1213.         while  (*dst++ = *src++);
  1214.       if  (fd = fopen (fnb, mode))return (fd);}
  1215.       while  (*path++);return (NULL);}
  1216.     C:>cb fopenp.c
  1217.  
  1218. gives as output:
  1219.  
  1220.   FILE *fopenp (path, fn, fnb, mode)
  1221.   register char *path;char *fn, *fnb, *mode;
  1222.   {
  1223.       ...
  1224.       if  (*fn == '\\')
  1225.         if  ( fd = fopen(fn, mode))
  1226.         {
  1227.           strcpy(fnb, fn);
  1228.           return (fd);
  1229.         }
  1230.         else
  1231.           return(NULL);
  1232.       do
  1233.       {
  1234.         while  ( *path != ';')
  1235.           *dst++ = *path++;
  1236.         if  (dst != fnb)
  1237.           *dst++ = '\\';
  1238.         while  (*dst++ = *src++);
  1239.         if  (fd = fopen (fnb, mode))
  1240.           return (fd);
  1241.       }
  1242.       while  (*path++);
  1243.       return (NULL);
  1244.   }
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254. [2] cb ----------------------------------------- The Berkeley Utilities V1.0
  1255.  
  1256.     C:>cb -on fopenp.c
  1257.  
  1258. gives as output:
  1259.  
  1260.   FILE *fopenp (path, fn, fnb, mode)
  1261.   register char *path;char *fn, *fnb, *mode;
  1262.   {
  1263.       ...
  1264.       if (*fn == '\\')
  1265.         if ( fd = fopen(fn, mode)) {
  1266.           strcpy(fnb, fn);
  1267.           return (fd);
  1268.         } else
  1269.             return(NULL);
  1270.       do {
  1271.         while ( *path != ';')
  1272.           *dst++ = *path++;
  1273.         if (dst != fnb)
  1274.           *dst++ = '\\';
  1275.         while (*dst++ = *src++);
  1276.         if (fd = fopen (fnb, mode))
  1277.           return (fd);
  1278.       } while (*path++);
  1279.       return (NULL);
  1280.   }
  1281.     C:>cb -rs fopenp.c
  1282.  
  1283. gives as output:
  1284.  
  1285.   FILE *fopenp (path, fn, fnb, mode)
  1286.   register char *path;char *fn, *fnb, *mode;
  1287.   {
  1288.       ...
  1289.       if  (*fn == '\\') if  ( fd = fopen(fn, mode))
  1290.       { strcpy(fnb, fn);
  1291.         return (fd);
  1292.       }
  1293.       else  return(NULL);
  1294.       do
  1295.       { while  ( *path != ';') *dst++ = *path++;
  1296.         if  (dst != fnb) *dst++ = '\\';
  1297.         while  (*dst++ = *src++);
  1298.         if  (fd = fopen (fnb, mode)) return (fd);
  1299.       }
  1300.       while  (*path++);
  1301.       return (NULL);
  1302.   }
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311. The Berkeley Utilities V1.0 ----------------------------------------- cb [3]
  1312.  
  1313. Bugs:
  1314.  
  1315.     If you ask for an output with both the options -r and -o, you won't get
  1316. exactly what you expect:   if there are nested  blocks,  the shift to  the
  1317. right of the output would very soon get unreadable.
  1318.  
  1319.     cb sends an explicit message in case of a syntax error:
  1320.                         ``else not following an if''
  1321.                                      or
  1322.                        ``unbalanced curly brackets''
  1323.  
  1324. But be careful ... cb is no syntax analyzer !
  1325.  
  1326.  
  1327. Portability:
  1328.  
  1329.     All options are enhancements (UNIX version cannot be configured).
  1330.  
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368. [4] cb ----------------------------------------- The Berkeley Utilities V1.0
  1369.  
  1370.                                           Look for common lines in two files
  1371.  
  1372.  
  1373. Synopsis:                    comm [options] file1 file2
  1374.  
  1375.     comm  works  on  two  already  sorted  files,  and  writes its  result  to
  1376. stdout.
  1377.  
  1378.  
  1379. Description:
  1380.  
  1381.     The default is to give the lines common to the two files.
  1382.  
  1383.  
  1384. Options:
  1385.  
  1386.     Two options are allowed on the command line:
  1387.  
  1388.     -1   Asks comm to give as output the lines which are only in file1.
  1389.     -2   Asks comm to give as output the lines which are only in file2.
  1390.  
  1391.  
  1392. Examples:
  1393.  
  1394.  
  1395.  
  1396.     C:\>ls -1 \util\src >files.c
  1397.     C:\>ls -1 a:util\src >files.a
  1398.     C:\>comm files.c files.a
  1399.  
  1400. Since, by default, the output of ls is  sorted alphabetically, comm  gives
  1401. the list of files which belong to both subdirectories.
  1402.  
  1403.     C:\>comm -2 files.a files.c
  1404.  
  1405. lists the files which appear only in the subdirectory C:\util\src .
  1406.  
  1407.  
  1408. See Also:
  1409.  
  1410.     diff, sort, uniq.
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425. The Berkeley Utilities V1.0 --------------------------------------- comm [1]
  1426.  
  1427.                                                   Copy files and directories
  1428.  
  1429.  
  1430. Synopsis:              cp [options] file|dir ... file|dir dir
  1431. or                           cp [options] source target
  1432. cp copies files or directories matched by the pathnames given as argument.
  1433.  
  1434. Description:
  1435. There are two forms of the command:
  1436.   o short  form:    there  are  only  two  arguments,  and  furthermore  both
  1437.     arguments consist of one file, or both of one directory, or the second
  1438.     argument is a new name.   The first argument is copied over the second
  1439.     (target).
  1440.   o long form:   the last argument is a directory (target)  and all  other
  1441.     arguments are copied to that target directory.
  1442. Watch out when using wild cards  (like file.*),  as the  target (the  last
  1443. argument) must expand to at most one name.
  1444.  
  1445. Options:
  1446.  
  1447.     The possible options on the command line are:
  1448.  
  1449.     -r   Allows cp to copy (and possibly overwrite) non-empty  directories
  1450.          (if not given, only empty directories are copied or overwritten).
  1451.     -m   When  copying  directories,  merges  the  source  with  the  target
  1452.          (instead of overwriting the target).
  1453.     -v   Gives on stdout a report on copied files.
  1454.     -f   Do  not  ask  confirmation  before  overwriting read-only  files  (by
  1455.          default the authorization of the user is asked).
  1456.  
  1457.     -i   Asks confirmation on the terminal before overwriting any file  or
  1458.          directory.
  1459.     -I   Asks  confirmation  on  the  terminal  before  copying  any  file  or
  1460.          directory.  This option implies the -i option.
  1461.     When the options -i or -I are given, the only answers allowed are:
  1462.  n: continue, do not overwrite or copy.
  1463.  q: leave.
  1464.  g: (go) stop asking questions.
  1465.  y: overwrite or copy.
  1466.  s: answer valid only for a directory.   Overwrite or copy without  asking
  1467.     further confirmations for files or sub-directories of this directory.
  1468.  
  1469.  
  1470. Examples:
  1471.  
  1472.  
  1473.     cp -rvm a:dbaseiv c:\
  1474.  
  1475. Add the contents of directory dbaseiv from diskette a:  to the hard disk c:
  1476. (and do not overwrite, if this directory already exists  on c:, the  files
  1477. in it whose name does not conflict with  a name in  a:dbaseiv);  inform on
  1478. performed actions (option -v).
  1479.  
  1480.  
  1481.  
  1482. The Berkeley Utilities V1.0 ----------------------------------------- cp [1]
  1483.  
  1484. Notes:
  1485.  
  1486.     MS-DOS's  COPY  is  capable  of  preventing  the copying  of a  file  over
  1487. itself  in  simple  cases,  but  will fail  in more  complicated cases  (which
  1488. trashes the file):
  1489.  
  1490.     C:\>COPY top.map top.map
  1491.     File cannot be copied onto itself
  1492.             0 file(s) copied
  1493.     C:\>COPY t*.map top.map
  1494.     1 file copied.
  1495.  
  1496. cp does not make that kind of mistake.
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539. [2] cp ----------------------------------------- The Berkeley Utilities V1.0
  1540.  
  1541.                                                      cut out selected fields
  1542.  
  1543.  
  1544. Synopsis:                        cut -clist [files]
  1545.  
  1546. or                          cut -flist [options] [files]
  1547.  
  1548.     cut cuts out columns or fields from each line of the files entered  as
  1549. arguments according to the options specified  by the user  on the  command
  1550. line.  If no files are specified or the file name -, cut works on stdin.
  1551.  
  1552.  
  1553. Description:
  1554.  
  1555.     cut looks at every line of files and copies to the standard output only
  1556. the fields (option -f) or characters (option -c) specified in the argument
  1557. list.  list must immediately follow the option (no space allowed).  list is
  1558. a comma-separated list of integers or integer ranges, given in  increasing
  1559. order.   A range is specified by a - as in 8-12.   A  - not preceded by  a
  1560. number makes cut consider that the range begins with the first character or
  1561. field.  A - not followed by a number means that the range ends at  the end
  1562. of the line, with the last character or field.
  1563.  
  1564. Options:  One of the two following options must appear on the command line:
  1565.     -clist list  represents  character  positions,   each  integer  is  the
  1566.            position of a character on the line:  for instance, the list -28
  1567.            asks cut to copy the first 28 characters of every line of files
  1568.            to the standard output.
  1569.     -flist list represents field positions,  each integer is the  position
  1570.            of  a  field  on  the line.    Fields  are delimited  by a  special
  1571.            character (see option -d).   If no delimiting character appears
  1572.            on  one  line,  this  line  will be  copied just  as it  is to  the
  1573.            standard output, unless option -s has been given.
  1574.     -dc    Take c as the delimiting character.   By default the fields are
  1575.            delimited by tabs.
  1576.     -s     Do not output lines containing no delimiters.
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596. The Berkeley Utilities V1.0 ---------------------------------------- cut [1]
  1597.  
  1598. Examples:
  1599.  
  1600.  
  1601.  
  1602.     C:\>cat junk
  1603.     apples 12 \kilos
  1604.     raisins 14 \pounds
  1605.     oranges 23 \units
  1606.     C:\>cut -c3-10 junk
  1607.     ples 12
  1608.     isins 14
  1609.     anges 23
  1610.     C:\>cut -f2 -d\ junk
  1611.     kilos
  1612.     pounds
  1613.     units
  1614.  
  1615.  
  1616. See Also:
  1617.  
  1618.     paste.
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653. [2] cut ---------------------------------------- The Berkeley Utilities V1.0
  1654.  
  1655.                                                 Compare files or directories
  1656.  
  1657.  
  1658.  
  1659. Synopsis:                      diff [options] f1...fn
  1660.  
  1661.     diff compares files or directories.  If the argument - is given, stdin
  1662. is used.
  1663.  
  1664.  
  1665. Description:
  1666.  
  1667.     When there are two arguments:   if they  are binary  files,  diff just
  1668. tells if they differ;  if they are text  files,  diff reports in a  format
  1669. similar to an ed script which lines must be  changed to make f1  identical
  1670. to  f2.    diff  gives  no  report when  the files  are  identical, except  if
  1671. the  option  -s described  below  has  been  given.   If  f1 and  f2 are  both
  1672. directories,  they are first sorted,  and then diff shows the files  which
  1673. appear in only one of them, and gives a report on files  or subdirectories
  1674. with the same name.   If there are more than two  arguments, the last  one
  1675. (fn) must be a directory, and for  each other argument  fi, diff  compares
  1676. fi and fn\fi.   If the option -r described below has not been given,  diff
  1677. reports common subdirectories, even if they are equal.
  1678.  
  1679.  
  1680. Options:
  1681.  
  1682.     The possible options are:
  1683.  
  1684.     -t Consider all files as binary, i.e.  just tell if they differ.
  1685.  
  1686.     -h (half-hearted)  Use  a  faster  algorithm  which  also  requires  less
  1687.        memory  for  big  files,  but  which  is  less  precise  and  may  give
  1688.        spurious results or no result at all (while the usual algorithm  is
  1689.        guaranteed to find the minimum necessary set of lines to change).
  1690.  
  1691.     -r Tells diff to work recursively on subdirectories.
  1692.  
  1693.     -s Give also a report on identical files.
  1694.  
  1695.     -b Ignore  final  whitespace  (blanks  and  tabs)  at the  end of  a  line
  1696.        and  consider  as  equal  any  other non-empty  sequence of  whitespace
  1697.        characters when comparing lines.
  1698.  
  1699.     Only one of the following options may be given at once:
  1700.     -e     Gives a true ed script.
  1701.  
  1702.     -f     Give an inverted script.
  1703.     -cn    Give n lines of context around each difference.   By default, 3
  1704.            lines are given.
  1705.  
  1706.     -Dname Useful mostly when dealing with C source files.  Gives on stdout
  1707.            a new file which has #ifdef's such that it  will compile as  f2
  1708.            if headed with #define name and as  f1 otherwise.   The  result
  1709.            might  not  compile  if  there  were  already #ifdef's  within  the
  1710. The BerkeleyiUtilities.V1.0 --------------------------------------- diff [1]
  1711.  
  1712. Examples:
  1713.     We show the output given by various options on the following two files:
  1714.     C:>cat a.c
  1715.     #define LINT_ARGS
  1716.     #include <stdio.h>
  1717.     main(){
  1718.     printf("hello, world!");
  1719.     }
  1720.     C:>cat b.c
  1721.     #include <stdio.h>
  1722.     main(){
  1723.     printf("hello, world!");
  1724.     exit(0);
  1725.     }
  1726. Default behavior:
  1727.     C:>diff a.c b.c
  1728.     <<< a.c  and b.c  differ >>>
  1729.     1d0
  1730.     < #define LINT_ARGS
  1731.     4a4
  1732.     > exit(0);
  1733. Option ``conditional compilation'':
  1734.     C:>diff -Dx a.c b.c
  1735.     #ifndef x
  1736.     #define LINT_ARGS
  1737.     #endif /* x */
  1738.     #include <stdio.h>
  1739.     main(){
  1740.     printf("hello, world!");
  1741.     #ifdef x
  1742.     exit(0);
  1743.     #endif /* x */
  1744.     }
  1745. Option ``ed script'':
  1746.     C:>diff -e a.c b.c
  1747.     4a
  1748.     exit(0);
  1749.     .
  1750.     1d
  1751.  
  1752. Bugs:
  1753.  
  1754.     The number of lines per file is limited to 32,000.
  1755.  
  1756. Portability:
  1757.     The options -r, -s  and -c  are only found in B.S.D. 4.xx.   Option -t
  1758. is an enhancement.  The use of different video attributes to highlight key
  1759. parts of the output is also an enhancement.
  1760.  
  1761. See Also:
  1762.     comm, ed, sed.
  1763.  
  1764.  
  1765.  
  1766.  
  1767. [2] diff --------------------------------------- The Berkeley Utilities V1.0
  1768.  
  1769.                                        display tree structure of directories
  1770.  
  1771.  
  1772. Synopsis:                     dtree [option] [pathname]
  1773.  
  1774.  
  1775. Description:
  1776.  
  1777.     dtree  displays  the  tree  structure  formed  by  subdirectories  of  the
  1778. directory  given  as  argument  on  the command  line.   By  default (when  no
  1779. argument  has  been  given)  dtree  works on  the current  directory.    Video
  1780. attributes  are  used  to  enhance  the  display of  different levels  in  the
  1781. hierarchy.
  1782.  
  1783.  
  1784. Option:
  1785.  
  1786.     The option -a also lists the files in each subdirectory.
  1787.  
  1788.  
  1789. Examples:
  1790.  
  1791.     C:>dtree \
  1792.     \windows\pif\
  1793.     \msc\include\----
  1794.          lib\
  1795.     \games\
  1796.     \dos\
  1797.  
  1798.  
  1799. Portability:
  1800.  
  1801.     The use of different video attributes to  highlight key  parts of  the
  1802. output is an enhancement.
  1803.  
  1804.  
  1805. See Also:
  1806.  
  1807.     ls -RM
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824. The Berkeley Utilities V1.0 -------------------------------------- dtree [1]
  1825.  
  1826.                                                                         echo
  1827.  
  1828.  
  1829. Synopsis:                    ech [-n] arg1 arg2 ... argn
  1830.  
  1831.  
  1832. Description:
  1833.  
  1834.     ech echoes its arguments, separated by a space, to stdout and adds  an
  1835. end-of-line after the last argument.   ech  may be  used to  find out  how
  1836. The Berkeley Utilities interpret command line arguments.
  1837.  
  1838.  
  1839. Option:
  1840.  
  1841.     The option -n tells ech not to add an end-of-line (\n) character after
  1842. the last argument.
  1843.  
  1844.  
  1845. Examples:
  1846.  
  1847.  
  1848.  
  1849.     C:\>ech Hello
  1850.     Hello
  1851.     C:\>ech $PATH
  1852.     \bin;\util;\dos
  1853.     C:\>ls *.dat
  1854.     C:\                    3 entries       123456 bytes
  1855.     abc.dat     def.dat     ghi.dat
  1856.     C:\>ech *.dat
  1857.     abc.dat def.dat ghi.dat
  1858.     C:\>cd \tc\include
  1859.     C:\TC\INCLUDE>ech  .
  1860.     c:\tc\include
  1861.     C:\TC\INCLUDE>ech  ..
  1862.     c:\tc
  1863.  
  1864.  
  1865. Portability:
  1866.  
  1867.     This command is called echo in UNIX systems, but since ECHO is also an
  1868. internal command of MS-DOS, we had to give it a different name.
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881. The Berkeley Utilities V1.0 ---------------------------------------- ech [1]
  1882.  
  1883.                                                                  Text editor
  1884.  
  1885.  
  1886.  
  1887. Synopsis:                        ed [options] [file]
  1888.  
  1889.     ed  edits  file  if  given  as  argument;  file  becomes  the  currently
  1890. remembered filename (see below; more precisely ed simulates the command ``e
  1891. file'' described below).   If no file argument has been given, the  edited
  1892. buffer starts empty with no current filename.
  1893.  
  1894.  
  1895.  
  1896. Description:
  1897.  
  1898.     Regular expressions are used within ed to specify line addresses and to
  1899. specify part of lines (in the s command).  Please consult the Appendix for
  1900. more information about regular expressions.
  1901. Options on the command line:  The possible options are:
  1902.  
  1903.     -s        ``Silent'':   suppresses  printing  of  a  character  and  line
  1904.               count  for  commands  e,  r  and w,  of  diagnostics when  using
  1905.               e  and  q  on  a  modified buffer,  and of  the prompt  !    for
  1906.               the command !command.   Keeps the inscrutable form of  error
  1907.               messages of UNIX's ed, that is error messages consisting of a
  1908.               simple ``?''.
  1909.  
  1910.     -p string Specifies a prompt string that will be used by ed in command
  1911.               mode.
  1912.  
  1913.     -f file   Takes the ed script (the sequence of commands to be executed)
  1914.               from file.
  1915.  
  1916. Addresses:
  1917.     Individual lines of the file to edit are specified by addresses  built
  1918. as follows:
  1919.  
  1920.     .         Represents the current line (which is usually the last  line
  1921.               affected by a command).
  1922.  
  1923.     $         Represents the last line of the edited file.
  1924.  
  1925.     n         Represents  the  nth  line  of  the  file  (n  is  an  integer,
  1926.               counting starts from 1.  As a special convention, 0 sometimes
  1927.               represents a place before the first line of the file).
  1928.     'x        Represents the line addressed by the label x,  where x is  a
  1929.               lower-case letter (these labels are created by the command k;
  1930.               see below).
  1931.  
  1932.     /pattern/ Represents  the  first  line  from  `.'  matched by  pattern  (a
  1933.               regular expression).   The search goes forward in the  file,
  1934.               and at the end of the file wraps back to the beginning, until
  1935.               a match is found or until  the search  goes back  up to  and
  1936.               including its starting line.
  1937.  
  1938. The Berkeley?UtilitiestV1.0/----------------------------------------- ed [1]
  1939.  
  1940.     +number   An  address  followed  by  +  or  -  followed  by  a  decimal
  1941.     -number   number means that the computed address must be increased (or
  1942.               decreased)  by  that  number  of  lines.    The  + sign  may  be
  1943.               omitted if the preceding address was nonempty.   An  address
  1944.               starting with + or - is computed with respect to the current
  1945.               line.  If no number is given after the + or - the number 1 is
  1946.               taken by default.  In additions several + or - can be given.
  1947.               For instance `++' is the same as `.+2'.
  1948. The commands:
  1949.     The ed commands take 0, 1, or 2 addresses.  When 2 addresses are given,
  1950. they are usually separated by a comma.  When two addresses are separated by
  1951. a semicolon, the current line (`.')   is set to the first address and only
  1952. then the second computed.  Several such addresses can be given and then the
  1953. last two are used for the  command.   For commands  taking two  addresses,
  1954. the second address must always specify a line after  the first one in  the
  1955. buffer, and the pair of addresses identifies the range of lines between the
  1956. two addresses.   A command which usually requires n addresses (n = 1 or 2)
  1957. and has been given fewer addresses assumes  default addresses.   When  one
  1958. address has been given to a two-addresses command, that address is taken as
  1959. default for the second address.  Finally ``%'' is equivalent to the address
  1960. pair 1,$.  All commands are given below preceded with the specification of
  1961. their default addresses within brackets.
  1962.     The first three commands below put ed in  insert mode.   In that  mode
  1963. any characters entered by the user  are taken  as text and  no command  is
  1964. recognized excepted that the character `.' given as only character on  its
  1965. line exits insert mode to go back to command mode.
  1966.  
  1967.   [.] a      Appends entered <text>  just after the addressed line.    The
  1968.       <text> address 0 means the beginning of  the file.   `.'  is set  to
  1969.       .      the last inserted line (to the addressed line if there was no
  1970.              <text> entered).
  1971. [.,.] c      Deletes  the  addressed  lines  and  replaces  them  by  entered
  1972.       <text> <text>.  `.' is set to the last entered line (to the next one
  1973.       .      if no line was entered).
  1974.   [.] i      Inserts entered <text> just before the addressed line.  `.' is
  1975.       <text> set to the last entered line (to the addressed line if no line
  1976.       .      was inserted).
  1977. Other commands:
  1978. [.,.] d         Deletes the addressed lines.  `.' is set to the line after
  1979.                 the last deleted line (if the last line of the buffer  was
  1980.                 deleted then `.' is set to the new last line).
  1981.       efile     In the first form, this command replaces the content of the
  1982.       e!command edited buffer with those of file.   `.' is set to the last
  1983.                 line read.   If no file name has been given, the currently
  1984.                 remembered  filename,  if  any,  is  read.    Otherwise  file
  1985.                 becomes the remembered filename for future e,  r, w and  f
  1986.                 commands.  In the second form command is sent to MS-DOS to
  1987.                 be executed, and its output (stdout) is read and  replaces
  1988.                 the contents of the buffer.   In that case the  remembered
  1989.                 filename is not changed.  In both forms, if the contents of
  1990.                 the buffer have been modified since the last w command, the
  1991.                 e command must be confirmed by repeating it.
  1992.  
  1993.  
  1994. [2] ed ----------------------------------------- The Berkeley Utilities V1.0
  1995.  
  1996.       Efile     This command is just like e,  except that no  confirmation
  1997.       E!command is asked in case of buffer modifications since the last  w
  1998.                 command.
  1999.       ffile     If  file  is  given,  this  command  changes  to  file  the
  2000.                 currently remembered filename.   Otherwise f just prints on
  2001.                 stdout the currently remembered filename.
  2002. [1,$] g/pattern/list First,  all  lines  containing  an  occurence of  pattern
  2003.                      are  marked.    Then  `.'  is  successively  set to  each
  2004.                      of  these  lines  and  the  list of  commands entered  is
  2005.                      executed.     The  list  of  commands  may  extend  over
  2006.                      several lines if each of them, excepted the last, ends
  2007.                      with a \.   The commands a, c and  i are allowed  and
  2008.                      insert mode is escaped either by a  solitary dot  (.)
  2009.                      or by a line not ending  with \.   Commands  g and  v
  2010.                      are not allowed in the list of executed commands.  An
  2011.                      empty list is equivalent to the p command.
  2012. [.,.+1] j         Joins  consecutive  lines  specified  by  the  addresses
  2013.                   (suppressing intervening newline characters).
  2014.     [.] kx        ``Labels''  with  x  the  addressed  line.    x  must  be  a
  2015.                   lower-case letter.   'x can then be used to address that
  2016.                   line.  `.' is left unchanged.
  2017.   [.,.] l         Prints  ``visibly''  the  addressed  lines:    that  is,
  2018.                   nonprintable  characters  such  as  `tab'  or `newline'  are
  2019.                   represented as in C by mnemonics and other non-printable
  2020.                   characters  are  represented  by  their  octal  code.    In
  2021.                   addition lines greater than screen width are folded.  `l'
  2022.                   may  be  added  as  a  flag to  any command  excepted e,  f,
  2023.                   r and w, and has then the effect of printing the new `.'
  2024.                   after execution of that command.
  2025.   [.,.] ma        Moves addressed lines to just after the lines  addressed
  2026.                   by a.   Address 0 is allowed  for a  meaning before  the
  2027.                   first line.   `.' is set to the new position of the last
  2028.                   moved line.
  2029.   [.,.] n         Prints addressed lines, preceded by their line number and
  2030.                   a tab.   `.' is set to the last printed line.   n may be
  2031.                   added as a flag to any command other than e, f, r and w,
  2032.                   and has then the effect of  printing the  new `.'  after
  2033.                   execution of that command.
  2034.  
  2035.   [.,.] p         Prints  addressed  lines.    `.'  is  set to  the last  line
  2036.                   printed.   p may be added as a flag to any command other
  2037.                   than e, f, r  and w, and has then the effect of printing
  2038.                   the new `.' after execution of that command.
  2039.         P         The prompt in command mode is  set to *  the first  time
  2040.                   this command is executed.   The prompt  is then  flipped
  2041.                   from * to empty on subsequent uses of P.
  2042.         q         Leaves ed without saving the buffer.   This command must
  2043.                   be confirmed by giving it twice if  the buffer has  been
  2044.                   modified since the last w command.
  2045.  
  2046.         Q         Leaves  ed;  does  not  ask  for  confirmation  even if  the
  2047.                   buffer has been changed.
  2048.  
  2049.  
  2050. The Berkeley Utilities V1.0 ----------------------------------------- ed [3]
  2051.  
  2052.     [$] rfile     In  the  first  form,  inserts  the  contents  of  file  in
  2053.         r!command the buffer just after the addressed  line.   If no  file
  2054.                   name  has  been  given,  the  remembered  filename is  used.
  2055.                   Otherwise, file becomes the currently remembered filename
  2056.                   only if it was the first name  given since entering  ed.
  2057.                   The address 0 is allowed, meaning before the first line.
  2058.                   The number of read lines and characters is printed,  and
  2059.                   `.' is set to the last read line.   In the second  form,
  2060.                   the  command  is  sent  to  MS-DOS to  be  executed and  its
  2061.                   output (stdout) is read into the buffer.   In that  case
  2062.                   the remembered filename is not changed.
  2063. [.,.] s/pattern/repl/  Does  substitutions  on  addressed  lines  containing
  2064.       s/pattern/repl/g the  pattern.    Depending  on  the  flags,  the  first
  2065.       s/pattern/repl/n occurence (no flags given), or all occurences (with
  2066.                        the g flag) or the nth occurrence of the pattern in
  2067.                        each of these lines will be replaced by the  string
  2068.                        repl.  Any character other than a space or a newline
  2069.                        can be used as a delimiter for the pattern and  the
  2070.                        replacement.    `.'  is  set  to  the  last line  where
  2071.                        the substitution occured.  Several characters have a
  2072.                        special meaning in repl.   & represents the part of
  2073.                        the line which matched the pattern, and \n where  n
  2074.                        is a single digit represents the part  of the  line
  2075.                        matched by the nth sub-regular expression (delimited
  2076.                        in pattern by \( and \)).  If repl consists only of
  2077.                        the character `%',  it is replaced by the value  is
  2078.                        had in the last s command.   The special meaning of
  2079.                        & and of \ and % can be  escaped by preceding  them
  2080.                        with another \.  It is possible to replace a line by
  2081.                        several lines by putting newlines in repl; each  of
  2082.                        these must be preceded by a \, so repl consists  of
  2083.                        several lines, all but the last ending in a \.  This
  2084.                        is not allowed within a g command.
  2085. [.,.] ta             This command copies addressed lines to just after the
  2086.                      line addressed by a.   `.' is set to the last  copied
  2087.                      line.  Address 0 is allowed for a.
  2088.       u              Undoes the last command which modified the buffer, i.e
  2089.                      the last command amongst a, c, d, g, i,  j, m, r,  s,
  2090.                      t and v.
  2091. [1,$] v/pattern/list This command is just like g, excepted that the list of
  2092.                      commands is effected on lines containing no match  of
  2093.                      the pattern.
  2094. [1,$] wfile          In  the  first  form,  the  addressed  lines are  written
  2095.       w!command      to file.   If no file name was  given,  the currently
  2096.                      remembered filename is used.   Otherwise, file becomes
  2097.                      the currently remembered filename only if it was  the
  2098.                      first name given since entering ed.    The number  of
  2099.                      written lines and characters is printed.   `.' is left
  2100.                      unchanged.   In the second form,  command is sent  to
  2101.                      MS-DOS to be executed, its standard input stdin being
  2102.                      a file consisting of the addressed  lines.   In  that
  2103.                      case the remembered filename is not changed.
  2104.  
  2105.  
  2106. [4] ed ----------------------------------------- The Berkeley Utilities V1.0
  2107.  
  2108.   [$] =              Prints the line number of the addressed line.  `.' is
  2109.                      not changed.
  2110.       !command       Sends command to MS-DOS to be executed.  If the first
  2111.                      character of the command is !, it is replaced by  the
  2112.                      last command executed by another !    command in  ed.
  2113.                      `.' is left unchanged.
  2114. [.+1]                An  address  alone  on  a  line  is  equivalent  to  the
  2115.                      command p.   A <CR>  alone on a line is equivalent to
  2116.                      the command `.+1p'.
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163. The Berkeley Utilities V1.0 ----------------------------------------- ed [5]
  2164.  
  2165.                                    Expands tabs to blanks in character files
  2166.  
  2167.  
  2168. Synopsis:             expand [-tabsize] [-tab1,tab2,...]file(s)
  2169.  
  2170.     Expands tabs to blank characters in character files given as argument,
  2171. prints the result to the console (stdout).  If no file arguments are given
  2172. or one of them is ``-'' the corresponding input is taken from  the console
  2173. (stdin).
  2174.  
  2175.  
  2176. Description:
  2177.  
  2178.     By  default  tab  stops  are  put  every  8 characters.    If  the  option
  2179. -tabsize is given, they are put instead every tabsize characters.
  2180.     If instead the option -tab1,tab2,... is  given,  tab stops are put  at
  2181. columns tab1, tab2, etc...(origin 0).
  2182.  
  2183.  
  2184.  
  2185.  
  2186.  
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192.  
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198.  
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220. The Berkeley Utilities V1.0 ------------------------------------- expand [1]
  2221.  
  2222.              find files with certain attributes and execute commands on each
  2223.  
  2224.  
  2225. Synopsis:                   find pathname-list predicate
  2226.  
  2227.     find  searches  for  files  matching  predicate,  down  in  the  directory
  2228. hierarchy below each argument of the pathname-list,  or by default,  below
  2229. the current directory.
  2230.  
  2231.  
  2232. Description:
  2233.  
  2234.     predicate is made of primary predicates, which are keywords preceded by
  2235. a - and followed by 0,  1  or more  arguments,  and combined with  logical
  2236. operators.  The operators are, in order of increasing precedence:
  2237.  
  2238.   o logical  or,  represented  by  the  argument  -o  appearing  between  two
  2239.     predicates.
  2240.     For example,  -name *.bak -o -name *.tmp is true  for each file  whose
  2241.     extension is .bak or .tmp.
  2242.  
  2243.   o logical and,  which is implicitly represented by the juxtaposition  of
  2244.     two predicates.
  2245.     For example -name *.bak -mtime 0 is true for each file whose extension
  2246.     is .bak,  and which has been created or  modified during  the last  24
  2247.     hours.
  2248.  
  2249.   o the  negation,  which  is  represented  by  the  argument !,  preceding  a
  2250.     predicate.
  2251.     For example ! -name *.bak is true for each file whose extension is not
  2252.     .bak.
  2253.   o Arguments  consisting  of  parentheses  are  used  to  group  predicates,
  2254.     changing the default order of precedence of the operators.
  2255.     For example ( -name *.bak -o -name *.tmp ) -mtime  0 is true for  each
  2256.     file whose extension is .bak or .tmp,  and which  has been created  or
  2257.     modified during the last 24 hours.  (since parentheses are just normal
  2258.     arguments on the command line, they must be preceded and followed by at
  2259.     least one space).
  2260.  
  2261.     By default, directories are looked at before their subdirectories  and
  2262. files.   The end of pathname-list (i.e.   the beginning  of predicate)  is
  2263. indicated by the first argument beginning with ``-'' or ''(''.
  2264.  
  2265.  
  2266. Syntax of ``predicate'':
  2267.  
  2268.     The  syntax  of  predicate  may  be  described  by  the  following  formal
  2269. grammar  (in  the  description,  ``iff''  stands for  ``if and  only if''  and
  2270. ''|'' stands for ``or''):
  2271.  
  2272. <predicate> := <conjunctive>
  2273.                    <predicate> is true iff <conjunctive> is true.
  2274.             |  <conjunctive> -o <conjunctive>
  2275.                    <predicate> is true iff one of the two <conjunctives> is
  2276.                    true.
  2277. The Berkeley Utilities V1.0 --------------------------------------- find [1]
  2278.  
  2279. <conjunctive> := <term>
  2280.                    <conjunctive> is true iff <term> is true.
  2281.  
  2282.               |  <term> <term>
  2283.                    <conjunctive> is true iff the two <terms> are true.
  2284.  
  2285. <term> := <primary predicate>
  2286.                    <term> is true iff <primary predicate> is true.
  2287.  
  2288.        |  !  <primary predicate>
  2289.                    <term> is true iff <primary predicate> is not true.
  2290.  
  2291. <primary predicate> :=  ( <predicate> )
  2292.                    <primary predicate> is true iff <predicate> is true.
  2293.  
  2294.                     |  <primary predicate>
  2295.                    One of the following predicates defined by keywords:
  2296.  
  2297. <primary predicate> :=  -name pattern
  2298.                    <primary predicate> is true iff the name of the current
  2299.                    file  is  matched  by  pattern.     pattern  may  contain
  2300.                    wild-cards  which  are  expanded  according  to  the  usual
  2301.                    rules for filename argument (for a precise description,
  2302.                    look in the general section of the documentation).
  2303.  
  2304.                     |  -perm permission
  2305.                    <primary predicate> is true iff the file has the  given
  2306.                    permission.  Two values can be specified for permission:
  2307.                    r: true for a read-only file.
  2308.                    w: true for a writable file.
  2309.  
  2310.                     |  -type filetype
  2311.                    <primary predicate> is true iff the file is of the given
  2312.                    type.  Two values can be specified for filetype:
  2313.                    f: true for an ordinary file.
  2314.                    d: true for a directory.
  2315.  
  2316.                     |  -size value
  2317.                    <primary predicate> is  true  iff  the  size  of  the  file
  2318.                    (given  in  kilobytes)  matches  the given  value.    Three
  2319.                    forms are recognized for value; n below is an integer:
  2320.                    n: true for files whose size is exactly n kilobytes.
  2321.                   +n: true for files whose size is more than n kilobytes.
  2322.                   -n: true for files whose size is less than n kilobytes.
  2323.  
  2324.                     |  -mtime value
  2325.                    <primary predicate>  is  true  iff  the  file  has  been
  2326.                    modified a number of days ago matching the given value.
  2327.                    Three  forms  are  recognized  for  value;  n below  is  an
  2328.                    integer:
  2329.                    n: true for files modified exactly n days ago.
  2330.                   +n: true for files modified more than n days ago.
  2331.                   -n: true for files modified less than n days ago.
  2332.  
  2333.  
  2334. [2] find --------------------------------------- The Berkeley Utilities V1.0
  2335.  
  2336.                     |  -newer filename
  2337.                    <primary predicate> is true iff the current file has been
  2338.                    created or modified more recently than filename.
  2339.                     |  -exec command
  2340.                    The  command  is  sent  to  MS-DOS  to be  executed,  where
  2341.                    command  is  a  sequence  of  arguments  ending  with  a
  2342.                    ``;''.   If one of the arguments is  {},  this argument
  2343.                    is  replaced  by  the  current  filename.    The  resulting
  2344.                    <primary predicate>  is  true  iff  the  executed  command
  2345.                    returns an exit status of 0 (success).  For example,
  2346.                    -exec grep -sw signal {} ;
  2347.                    is  true  for  the  files  which  contain  at  least  one
  2348.                    occurrence of the word signal.
  2349.                     |  -ok command
  2350.                    Like ``-exec'',  but command is echoed to the  terminal
  2351.                    before  execution  and  the  user  is  asked  wether  it
  2352.                    should  be  executed.     If  the  answer  is  negative,
  2353.                    <primary predicate> is false.  For example,
  2354.                    -ok cat {} ;
  2355.                    asks  if  the  current  file  should  be  copied  to  the
  2356.                    terminal;  if  the  answer  is  positive,  the  following
  2357.                    predicates will be applied on the current file after its
  2358.                    printing.  If the answer was negative, find works on the
  2359.                    next file.
  2360.                     |  -print
  2361.                    This <primary predicate>  is always true, and causes the
  2362.                    current path-name to be printed on the standard output.
  2363.  
  2364.                     |  -depth
  2365.                    This  <primary predicate>  is  always  true,  and  forces
  2366.                    the  directories  to  be  looked at  after  their files  or
  2367.                    sub-directories.
  2368.  
  2369. Beware:  operators ( !, -o, (, ) ) must be separated by one or more spaces
  2370. from the predicates, arguments and other operators.
  2371.  
  2372.  
  2373. Examples:
  2374.     In  order  to  delete  the  files older  than a  week  whose extension  is
  2375. .bak  or  .tmp,  down  from  applis in  the hierarchy:   find  applis (  -name
  2376. *.bak -o -name *.tmp ) -mtime +7 -exec rm -i {} ;
  2377.  
  2378.  
  2379. Error Messages:
  2380.  
  2381. ``predicate-list error''
  2382.     The analysis has found the end of predicates, but the command line  is
  2383. not finished.
  2384. ``unbalanced parentheses''
  2385.     There is a missing closing parenthesis.
  2386. ``predicate xxx unknown''
  2387.     or
  2388.  
  2389.  
  2390.  
  2391. The Berkeley Utilities V1.0 --------------------------------------- find [3]
  2392.  
  2393. ``xxx found when expecting predicate''
  2394.     Another  token  was  found  at  a  place  where  a keyword  predicate  was
  2395. expected.
  2396. ``incomplete statement''
  2397.     The argument of -exec or -ok doesn't end with a ``;''.
  2398. ``can't access xxx''
  2399.     The argument of -newer cannot be found or looked at.
  2400. ``xxx: no match''
  2401.     An argument in pathname-list doesn't exist.
  2402.  
  2403.  
  2404. Portability:
  2405.  
  2406.     The -depth option is an enhancement.
  2407.  
  2408.  
  2409. See Also:
  2410.  
  2411.     Command line expansion of ``\\'' in the section entitled "Calling  the
  2412. Utilities".
  2413.  
  2414.  
  2415.  
  2416.  
  2417.  
  2418.  
  2419.  
  2420.  
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.  
  2448. [4] find --------------------------------------- The Berkeley Utilities V1.0
  2449.  
  2450.                                           Search for a text pattern in files
  2451.  
  2452.  
  2453.  
  2454. Synopsis:                 grep [options] [pattern] [files]
  2455.  
  2456.     grep works on the given argument files.  If no argument or the argument
  2457. - has been given, grep takes its input from stdin.
  2458.  
  2459.  
  2460. Description:
  2461.  
  2462.     grep searches for occurrences of a pattern (regular expression) in each
  2463. of  the  argument  files  and  gives on  stdout the  list of  lines where  the
  2464. pattern has been found.  Video attributes are used to show the part of the
  2465. line which matches the specified pattern.   To get more information on the
  2466. syntax and usage of regular expressions, look at the Appendix.
  2467.  
  2468.  
  2469. Options:
  2470.  
  2471.     The possible options on the command line are:
  2472.  
  2473.     -s      This  option  tells  grep  to give  no  output but  to report  the
  2474.             result of the search with a return code as follows:
  2475.               0 no match found.    1 a match found.    2 some error.
  2476.  
  2477.     -c      Only give a count of matched lines for each file.
  2478.  
  2479.     -l      Only give the names of the files containing a match.
  2480.  
  2481.     -h      Do not output in front of matched lines the  name of the  file
  2482.             where the line was found (the default is to output it).
  2483.  
  2484.     -n      Give line numbers of matched lines.
  2485.  
  2486.     -t      Stop the search at the first match in each file.
  2487.     -i      Do not take into account lower-case  / upper-case  distinction
  2488.             when searching.
  2489.  
  2490.     -w      Match only complete words.
  2491.     -x      Match only complete lines.
  2492.  
  2493.     -v      Instead of giving lines containing a match, give lines which do
  2494.             not contain a match.
  2495.     -e expr Giving a pattern as argument to the  -e option  allows one  to
  2496.             give a pattern beginning by the character -,  and can also  be
  2497.             used to look for several patterns simultaneously (if there are
  2498.             multiple -e options).
  2499.  
  2500.     -f file This  option  also  allows  several  patterns;   the  argument
  2501.             specifies a file containing patterns to look  for,  giving one
  2502.             per line.
  2503.  
  2504.     -V      Take the pattern verbatim, i.e.   do not interpret any of  the
  2505. The BerkeleysUtilitiesgV1.0 --------------------------------------- grep [1]
  2506.  
  2507. Examples:
  2508.  
  2509.  
  2510.  
  2511.     C:\TC\MCALC>grep video *.c
  2512.  
  2513.     mcdisply.c:/* Prints a string in ----- memory at a selected location */
  2514.  
  2515. The following example gives the names of all functions in a C program file
  2516. whose name have less than 16 characters, as long as their name is given at
  2517. the beginning of a line.
  2518.  
  2519.     C:\>grep "^[a-zA-Z][0-9a-zA-Z]\{0,15\} \{0,1\}(" file.c
  2520.  
  2521.     ------------)
  2522.     --------mess)
  2523.     -------)
  2524.     -------c)
  2525.  
  2526.  
  2527. Notes:
  2528.  
  2529.     grep was created around 1973, but was soon considered too slow.  fgrep
  2530. (fast grep) was then written and can  handle several words  at once,  each
  2531. without metacharacters.   egrep (extended grep) came later,  incorporating
  2532. every feature and adding many more (for instance |, which means ``or'', and
  2533. is not yet implemented in version 1.0).  grep should disappear on UNIX, but
  2534. has not, and in fact is a nuisance, as many UNIX users will type grep when
  2535. they should use egrep.   Our grep is very close to egrep,  and the use  of
  2536. option -V in our version 1.0 turns grep into fgrep.
  2537.  
  2538.  
  2539. Portability:
  2540.  
  2541.     The use of different video attributes to  highlight key  parts of  the
  2542. output is an enhancement.
  2543.     Options -w, -V and the second part of option -e are also enhancements.
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562. [2] grep --------------------------------------- The Berkeley Utilities V1.0
  2563.  
  2564.                                                   list files and directories
  2565.  
  2566.  
  2567. Synopsis:                     ls [options] [arguments]
  2568.  
  2569.     ls gives the list of files and directories  matched by the  arguments,
  2570. first files, then directories and their contents,  sorted by  name.   Used
  2571. with the wild-card expansion built in The Berkeley Utilities, the  various
  2572. options of ls create a powerful way to look at the contents of a disk.
  2573.  
  2574.  
  2575. Description:
  2576.  
  2577.     ls  puts  in  front  of  the  list  (and  of  any sublist  relative  to  a
  2578. directory  whose  contents  are  listed)  a header  indicating  the number  of
  2579. entries and the space taken by the files in the list.
  2580.  
  2581.  
  2582. Options:
  2583.  
  2584.     The possible options on the command line are:
  2585.  
  2586. list selection options:
  2587.  
  2588.     -a List  of  all  entries,  including  ``hidden''  files,  system  files,
  2589.        `.' and `..'.
  2590.     -A Same list but omits `.' and `..'.
  2591.     -D List only directories.
  2592.     -d Do not list the content of the arguments which are directories, just
  2593.        give their names.
  2594.     -F List only files.
  2595.     -R Recursively list subdirectories.   When combined with the option -1,
  2596.        names are given with their complete pathnames.
  2597. sort options:
  2598.  
  2599. The default is an alphabetic sort on filenames.
  2600.  
  2601.     -e Alphabetic sort by extension.
  2602.     -t Sort  by  time  of  last  modification,  the  most recent  time  listed
  2603.        first.
  2604.     -L Sort by decreasing size.
  2605.     -r Reverse the specified sorting order.
  2606.     -f Do not sort.
  2607.  
  2608. report options:
  2609.  
  2610.     -x The list is laid out left to right, line by line (the default is top
  2611.        to bottom and left to right, column by column).
  2612.     -1 Give the list on a single column (this is the default if the output
  2613.        of ls is redirected to a file).
  2614.     -C Multi-column report, with a header for each directory (this is  the
  2615.        default when the output of ls is to a terminal).
  2616.  
  2617.  
  2618. The Berkeley Utilities V1.0 ----------------------------------------- ls [1]
  2619.  
  2620.     -M Gives only the headers (useful with the option -R to make a  survey
  2621.        of a subdirectory hierarchy).
  2622.     -m List the entries with their full pathnames, separated by commas.
  2623.     -p Decorate directory names by appending to their names a \.
  2624.     -s Give the size in bytes of each entry.
  2625.     -T Give last time modified for each entry.
  2626.     -l Complete list:   corresponds to options -sT,  with in addition  the
  2627.        flags -|d|s|c which mean respectively ordinary file|directory|system
  2628.        file|special  character  file  (e.g.    con:   or  prn:), -|h  ordinary
  2629.        file|hidden file and r|w read-only|read and write.
  2630. size options:
  2631.  
  2632.     -U[unit]   Rounds up individual sizes to a multiple of the cluster size
  2633.      or        of unit.   By default the disk unit of  the first  argument
  2634.      Unumber   is  taken.    Free  space  left  on  the  disk is  also  given.
  2635.       of bytes An  explicit  cluster  size  (in  bytes) may  given instead  of
  2636.                a  unit  name.    This  option  allows us  to  know the  actual
  2637.                size taken by the files on the  disk (the operating  system
  2638.                always allocates an integral number of clusters to a file),
  2639.                and  also  to  know  the  size  they would  take if  they  were
  2640.                transferred to the disk whose unit was given as argument to
  2641.                the -U  option.   It worth noting that a given set of files
  2642.                probably uses a lot more space  on a  hard disk  than on  a
  2643.                floppy because its clusters are usually larger.
  2644.  
  2645. Examples:
  2646.     In this example, ls lists each of the subdirectories with its size,  a
  2647. very valuable piece of information when the disk is nearly full.
  2648.     C:\>ls -RM
  2649.     c:\                                                5 entries      115900 bytes
  2650.     c:\dease\                                         15 entries      552217 bytes
  2651.     c:\jc\                                            11 entries      146038 bytes
  2652.  
  2653. In this example, ls lists all the EXEcutable files with a filename starting
  2654. in e, somewhere in or below the current directory.
  2655.     D:\MSC>ls .\\e*.exe
  2656.     .\\e*.exe                                          7 entries      102539 bytes
  2657.     .\bin\errout.exe    .\bin\exepack.exe   .\exe2bin.exe       .\me\bin\exp.exe
  2658.     .\bin\exemod.exe    .\errshow.exe       .\me\bin\ech.exe
  2659.  
  2660. In the following example, ls lists the sidekick subdirectory and shows the
  2661. space it would take if transferred to a:  (237056 bytes for  the contents,
  2662. 237568 bytes if the directory sidekick is also created on a:); we see that
  2663. there is enough space left on a:   to transfer it (there are 803840  bytes
  2664. left).
  2665.     D:\>ls -Ua \sidekick
  2666.     \sidekick\                                        10 entries      237056 bytes
  2667.     notes           read-me.sk      sk.hlp          skinst.com      skm.com
  2668.     phone.dir       sk.com          skc.com         skinst.msg      skn.com
  2669.             === total: 237568 bytes= 20% of capacity of unit a:  ===
  2670.     unit a: 512 bytes/sector 512 bytes/cluster 803840 bytes left (66.2%)
  2671.  
  2672.  
  2673.  
  2674.  
  2675. [2] ls ----------------------------------------- The Berkeley Utilities V1.0
  2676.  
  2677. Portability:
  2678.  
  2679.     The option -A is taken from the Berkeley Unix system.
  2680.     The use of different video attributes to  highlight key  parts of  the
  2681. output is an enhancement.
  2682.     The options -e, -L, -M, -T and -U are also enhancements.
  2683.  
  2684.  
  2685. See Also:
  2686.  
  2687.     Command line expansion in the section entitled "Calling the Utilities".
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732. The Berkeley Utilities V1.0 ----------------------------------------- ls [3]
  2733.  
  2734.                                                                 update files
  2735.  
  2736.  
  2737. Synopsis:              make [options] [targets] [definitions]
  2738.     make  finds  out  the  minimum sequence  of  commands needed  to update  a
  2739. program  or  a  group  of  programs  when some  of the  files  they depend  on
  2740. have been modified (are more recent)  and then executes  that sequence  of
  2741. commands.
  2742.  
  2743.  
  2744. Description:
  2745.     Among  the  arguments  that  are  not options,  those  containing a  ``=''
  2746. are treated separately (see macro definitions), the others are the targets
  2747. to update.   make reads one or more description files  specified by an  -f
  2748. option (see below), and if there was no  -f option,  by default, the  file
  2749. ``makefile'' in the current directory.   make interprets  the contents  of
  2750. these  files  as  a  sequence  of rules  giving the  dependencies between  the
  2751. targets (non-existent names or file names) and other files, and the actions
  2752. to execute (methods) in order to create a target if the file doesn't exist,
  2753. or  to  update  it  if  it exists  and is  older than  its dependents.    make
  2754. updates the targets specified on the  command line or  the first  ``real''
  2755. target found in the first description file if no  target was specified  on
  2756. the command line, or all targets if the -a option has  been given.   Rules
  2757. and methods are applied recursively, i.e.   if one dependent is not up  to
  2758. date,  it will be updated before going on.   Whether  description file  is
  2759. explicitly given on the command line or not, make first loads the built-in
  2760. rules except if the -r  option is given.   Those built-in rules are  taken
  2761. from  the  file  make.ini  if  such a  file can  be found  in the  directories
  2762. specified  by  the  environment  variable  path  (starting  with  the  current
  2763. directory), otherwise make will use only the few  rules compiled into  it.
  2764. In order to send the built-in rules to the terminal, enter:
  2765.                                make -f nul -p
  2766.     (see the -p option below).
  2767.  
  2768.  
  2769. Contents of description files:
  2770.   o ``#'' starts a comment and everything appearing between a ``#'' and the
  2771.     end of the line is ignored, the newline included.
  2772.   o Blank lines are also ignored but may be used to terminate entries.
  2773.   o Lines that do not begin with <Tab> and containing a ``='' not preceded
  2774.     by a ``:''  are macro definitions.
  2775.   o The following lines are grouped to form entries:
  2776.       - The first line of an entry,  called a  rule,  must be a  non-empty
  2777.         sequence of blank delimited targets, followed by ``:''  or ``::'',
  2778.         and  followed  by  a  dependents  list that  may be  empty.    targets
  2779.         and dependents are sequences of characters representing legal file
  2780.         specifications.  Drive specifications (ex.:  a:)  are accepted, but
  2781.         bring a new constraint for the syntax of this line:  if the targets
  2782.         and the dependents are separated by an single ``:''  and if the last
  2783.         target is a one-character name, this ``:''  must be followed by at
  2784.         least one blank.  The targets beginning with a ``.''  and containing
  2785.         neither ``\'' nor ``/'' are called pseudo-targets.
  2786.  
  2787.  
  2788.  
  2789. The Berkeley Utilities V1.0 --------------------------------------- make [1]
  2790.  
  2791.       - The end of the line after an eventual  ``;''  , and the  following
  2792.         lines beginning with a <Tab>, are the commands to execute in order
  2793.         to  update  targets  if  the  updated dependents  are  newer.    These
  2794.         commands are called methods.  A line that doesn't begin with a <Tab>
  2795.         or a ``#'' terminates the entry.  A method may be several lines long
  2796.         if every line except the last one ends with a ``\''.  The <Tab> at
  2797.         the beginning of a method may be followed  by one  or both of  the
  2798.         characters ``-'' and ``@''.   ``-'' causes make to ignore an error
  2799.         status returned by this given method even if the -i option was not
  2800.         given, and ``@'' prevents displaying that method before  execution
  2801.         except if the -n option was given (see those options below).
  2802.  
  2803.   o A target may appear several times, with the following restrictions:
  2804.       - A target may not appear left of ``:''  and later left of ``::''.
  2805.       - If a target followed by ``:'' appears in several entries, only one
  2806.         of these entries may contain methods.  If a dependent in any entry
  2807.         is newer than target, these methods are executed, and the inference
  2808.         rules are not examined.  If no method was given, make looks for an
  2809.         inference rule to apply (see below).
  2810.       - If a target followed by ``::'' appears in several entries, several
  2811.         of these entries may contain lines of methods.  In which case, if a
  2812.         dependent in an entry is newer than the target, the methods  given
  2813.         for this entry are executed.  The inference rules are also executed
  2814.         if applicable.
  2815.       - The dependents of each occurence of a target accumulate, except for
  2816.         the pseudo-target ``.SUFFIXES''.
  2817.  
  2818.  
  2819.  
  2820. Pseudo-targets:
  2821.  
  2822.     The following pseudo-targets have a special meaning for make:
  2823.  
  2824.     .SUFFIXES The dependents have a name beginning with  a ``.'',  usually
  2825.               conventional  suffixes  for  files.    They  are  used  by  the
  2826.               inference rules (see below).   An entry ``.SUFFIXES'' without
  2827.               any dependents cancels all formerly declared suffixes.
  2828.  
  2829.     .DEFAULT  If make finds no rules, neither explicit ones nor  inference
  2830.               rules  giving  methods  for  a  target,   and  if  an  entry
  2831.               ``.DEFAULT'' is found, the methods following this entry will
  2832.               be applied.
  2833.  
  2834.     .PRECIOUS If an user interrupt (^C) takes place during the updating of
  2835.               a file, this file is deleted unless it is a dependent of the
  2836.               pseudo-target ``.PRECIOUS''.
  2837.  
  2838.     .IGNORE   This pseudo-target forces the ``ignore errors'' mode, just as
  2839.               if the -i option had been given on the command line.
  2840.  
  2841.     .SILENT   This pseudo-target forces the ``silent'' mode just as if the
  2842.               -s option had been given on the command line.
  2843.  
  2844.  
  2845.  
  2846. [2] make --------------------------------------- The Berkeley Utilities V1.0
  2847.  
  2848.     The  other  pseudo-targets  recognized  by  make  are  those  built  by
  2849. catenating two suffixes,  and are called inference rules.   Typically,  an
  2850. entry for a pseudo-target ``.c.obj'' specifies a method to update the file
  2851. name.obj from the file name.c if no explicit rule is found,  i.e.   if the
  2852. target name.obj doesn't appear explicitly.
  2853.  
  2854.  
  2855.  
  2856.  
  2857.  
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864.  
  2865.  
  2866.  
  2867.  
  2868.  
  2869.  
  2870.  
  2871.  
  2872.  
  2873.  
  2874.  
  2875.  
  2876.  
  2877.  
  2878.  
  2879.  
  2880.  
  2881.  
  2882.  
  2883.  
  2884.  
  2885.  
  2886.  
  2887.  
  2888.  
  2889.  
  2890.  
  2891.  
  2892.  
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901. Examples:
  2902.  
  2903. The Berkeley Utilities V1.0 --------------------------------------- make [3]
  2904.  
  2905.     Let us look at an example of a makefile :
  2906.  
  2907.         # compiler options:
  2908.         CFLAGS=/DLINT_ARGS
  2909.         # linker options:
  2910.         LFLAGS=/noi
  2911.         #
  2912.         # to cancel the eventual suffixes in "make.ini" ,
  2913.         # and accept only the ".c" et ".obj" suffixes:
  2914.         #
  2915.         .SUFFIXES:
  2916.         .SUFFIXES: .c .obj
  2917.         # compile method:
  2918.         .c.obj:
  2919.             msc $(CFLAGS) $*;
  2920.         # list of all source files:
  2921.         FILES=main.c sub1.c sub2.c
  2922.         # main target, building the application:
  2923.         main.exe: $(FILES:.c=.obj)
  2924.             link $(LFLAGS) $(FILES:.c);
  2925.         #auxiliary target, for floppy backup:
  2926.         backup:$(FILES)
  2927.             cp $? a:
  2928.             touch backup -f
  2929.  
  2930. The lines beginning with a # are  ignored.   The lines ``CFLAGS=...''  and
  2931. ``LFLAGS=...'' are macro definitions, used to give a values to the compiler
  2932. and linker options (which can be easily changed by  arguments on the  make
  2933. command line or with environment variables;  see below).   The next  lines
  2934. cancel the suffixes possibly declared in the built-in rules and declare as
  2935. only recognized suffixes .c and .obj; next the  default rule to obtain  an
  2936. object module from a C source  is given.   Then  a new  macro is  defined,
  2937. and the targets main.exe and backup are successively declared, with  their
  2938. dependents and the methods to update them.  The target main.exe is the main
  2939. target, i.e.  the default target if no target is given on the command line,
  2940. because it is the first true target occuring in the description file.
  2941.  
  2942.  
  2943.  
  2944. Macro substitution:
  2945.  
  2946.     In  any  line  of  a  description  file,  the  character  ``$''  starts  a
  2947. substitution.  Macro calls may take several forms:
  2948.   1 $(x), where x is a string containing neither ``('' nor ``:''.
  2949.   2 $(x:y),  where  x  contains  no  ``)'' and  y contains  neither ``)''  nor
  2950.     ``=''.
  2951.   3 $(x:y=z), where neither x nor y nor z contain any ``)''.
  2952. The parentheses may be replaced by curly brackets;  in form 1,  if x is  a
  2953. one-character string, they may be left out.   In form 1, x is replaced  by
  2954. the ``value'' of the so called  macro (by  the empty string  if the  macro
  2955. is not defined).   In form 3, for each  substitution, all non  overlapping
  2956. occurences of the string y in the value of x are replaced by z.  Form 2 is
  2957. similar to form 3 with z being an empty string.
  2958.  
  2959.  
  2960. [4] make --------------------------------------- The Berkeley Utilities V1.0
  2961.  
  2962.     For  example,  with  the  preceding  makefile  , after  substitution,  the
  2963. entry of the file dealing with ``main.exe'' becomes:
  2964.  
  2965.         main.exe: main.obj sub1.obj sub2.obj
  2966.             link /noi main sub1 sub2;
  2967.  
  2968. The  part  before  the  definition  of  ``FILES''  in  makefile  could  be  in
  2969. make.ini.
  2970.     Some macros are predefined in make, and  can't be explicitly  assigned
  2971. to:
  2972. The following macro always has the same value:
  2973.   - $$ always has the value $.
  2974. The  following  macros  see  their  values changed  according  to the  current
  2975. rule:
  2976.   - $* is meaningful only in the methods for an inference rule.  Its value
  2977.     is the dependent's name less the suffix, which is also the name of the
  2978.     target less the suffix.
  2979.   - $< is meaningful only in a method for an inference rule or a  .DEFAULT
  2980.     rule.  Its value is the entire dependent's name.
  2981.   - $@ is meaningful only in a method for an explicit rule.   Its value is
  2982.     the entire target's name.
  2983.   - $? is meaningful only in a method for an explicit rule.   Its value is
  2984.     the list of the dependents that should be updated.
  2985. The first three macros have two  variants:   if ``F''  is appended  (e.g.,
  2986. $(*F)), the ``directory'' part of the name is stripped from the value.  If
  2987. ``D'' is appended (e.g., $(@D)), only the ``directory'' part is kept (.\ if
  2988. that part would be empty).  The other macros may explicitly be given values
  2989. in the following ways:
  2990.   1 On  the  command  line,  through  an  argument  of  the  form  x=v;  these
  2991.     definitions take effect before any other action and can't be  modified
  2992.     by redefinitions in make.ini or a description file.
  2993.   2 Indirectly,  through environment variables.   Any environment variable
  2994.     which has a value is considered as defining a macro with the same name
  2995.     and value.
  2996.   3 By a line of the form x=v in the description file.
  2997.   4 Through  the  execution  of  a method  whose  command is  set (which  thus
  2998.     defines an environment variable).
  2999. By default,  2 takes place before 3,  and definitions  in the  description
  3000. files supersede previous ones.  The -e option changes that default but the
  3001. environment variable MAKEFLAGS is always read first.
  3002.  
  3003.     For  example,  with  the  preceding  makefile ,  if the  files main.c  and
  3004. sub2.c have been modified since the last main.exe, the command
  3005.  
  3006.         make
  3007.  
  3008. will force the execution of:
  3009.  
  3010.         msc /DLINT_ARGS main.c;
  3011.         msc /DLINT_ARGS sub2.c;
  3012.         link /noi main sub1 sub2
  3013.  
  3014. The command
  3015.  
  3016.         make CFLAGS= LFLAGS=/noi/exepack
  3017. The Berkeley Utilities V1.0 --------------------------------------- make [5]
  3018.  
  3019. will force the execution of:
  3020.  
  3021.         msc main.c;
  3022.         msc sub2.c;
  3023.         link /noi/exepack main sub1 sub2
  3024.  
  3025. and the command
  3026.  
  3027.         make backup
  3028.  
  3029. will force the execution of:
  3030.  
  3031.         cp main.c sub2.c a:
  3032.  
  3033.     Another macro has a special meaning for make:  The presence of $(MAKE)
  3034. in a method forces the execution of  that line  even if the  -n option  is
  3035. given.  (see below).
  3036.  
  3037.            Beware  :   for  the  macros  in  the  rules (up  to an
  3038.            eventual ``;''),  the substitution takes place when
  3039.            description  file  is  read.    But  in  the  lines  of
  3040.            methods, the substitutions are computed again before
  3041.            each execution.
  3042.  
  3043.  
  3044. Options:
  3045.     The following options are available on the command line:
  3046.     -a      Update every true target of the given description files.
  3047.     -px     Print the information used by make on standard output; x may be
  3048.             a subset of:
  3049.               m Macros.
  3050.               s Suffixes
  3051.               i Inference rules.
  3052.               e Explicit rules.
  3053.                 If no x is given, ``msie'' is the default.
  3054.     -f file file is the name of a description file.  By default, make takes
  3055.             makefile.  The - argument causes make to use stdin.
  3056. The following options invoke modes and may be forced if the  corresponding
  3057. letter  is  found  in  the  environment  variable ``MAKEFLAGS''.  After  their
  3058. value is established, the new value of MAKEFLAGS is computed and  exported
  3059. to subshells.
  3060.     -d Prints the information about the files and their dates on which make
  3061.        bases its decisions.
  3062.     -e The  values  of  the  environment  variables  override  the   macro
  3063.        definitions of the description files.
  3064.     -i Normally an exit status different from 0 returned by a method causes
  3065.        make to terminate execution.   If this option is  given,  make will
  3066.        ignore error codes returned by the commands.  This option is forced
  3067.        if the pseudo-target ``.IGNORE'' appears in the description files.
  3068.  
  3069.     -k If the -i option is not given and if a command fails, make continues
  3070.        the execution of the entries not depending on the current target.
  3071.  
  3072.  
  3073. [6] make --------------------------------------- The Berkeley Utilities V1.0
  3074.  
  3075.     -q Checks if target is up to date:   returns a status code of 0 if  it
  3076.        is, -1 otherwise.
  3077.     -n Execute no commands:   just display them on the terminal, including
  3078.        commands preceded by ``@''.   Commands on method lines which contain
  3079.        the ``$(MAKE)'' macro will nevertheless be executed.
  3080.     -r Do not use built-in rules.
  3081.     -s ``silent''  mode:   Do  not  display  the  commands  before  execution.
  3082.        This option is forced if the pseudo-target  ``.SILENT'' appears  in
  3083.        the description files.
  3084.     -t ``touch'' (give the current date to) the targets without  executing
  3085.        any command.
  3086.  
  3087.  
  3088. Error Messages:
  3089.  
  3090. The following errors are fatal:
  3091. ``cannot open xxx''
  3092.     Couldn't open a description file specified by an -f option.
  3093. ``Bad character c (hex x), line d''
  3094.     A lexical error has been found in a description file.
  3095. ``syntax error''
  3096.     A syntax error has been found in a description file.
  3097. ``yacc stack overflow''
  3098.     The description file is too complex for the syntax analyser.
  3099. ``Must be a separator on rules line xxx''
  3100.     Either a ``:''  in a rule line, or a <Tab> in a method line is missing.
  3101. ``description file error''
  3102.     An error has been detected in a description file.
  3103. ``fatal error executing xxx''
  3104.     A command returned a status different from 0.
  3105. ``cannot execute xxx''
  3106.     Couldn't  execute  a  command:   no  executable  with this  name could  be
  3107. found in the directories specified by  the environment  variable path,  or
  3108. there was not enough memory available to execute it,  or the command  line
  3109. length was more than 127 characters (an MS-DOS limitation).  This last case
  3110. may come from too long a macro expansion, especially $?.
  3111. ``interrupted by user''
  3112.     A ^C has been sent by the user.
  3113. ``Excessive macro nesting level''
  3114.     A nested macro definition exceeds make's capacity.
  3115. ``symbol table overflow''
  3116.     The number of targets and dependents exceed make's capacity.
  3117. ``line too long''
  3118.     A  line  from  a  description  file exceeds  the size  of  the line  input
  3119. buffer (2500 characters).
  3120. ``out of memory''
  3121.     make needs more memory for this job.
  3122. The following error is fatal only if the -k option is not given.
  3123. ``don't know how to make xxx''
  3124.     The required rule couldn't be found.
  3125. The following messages are warnings:
  3126. ``$? list too long.''
  3127.     Buffer overflow during expansion of $?, which is then truncated.
  3128.  
  3129.  
  3130. The Berkeley Utilities V1.0 --------------------------------------- make [7]
  3131.  
  3132. ``file xxx does not exist.''
  3133.     In case of a -t option, a target file needed to be created by ``touch''
  3134. before it could be set to the current date.
  3135. ``Cannot touch xxx''
  3136.     In case of a -t option, a file could not be set to the current date.
  3137. ``Inconsistent rules lines for `xxx'''
  3138.     A target can't be followed once by ``:''  and later by ``::''.
  3139. ``Multiple rules lines for `xxx'''
  3140.     A  target  followed  by  ``:''   is  in  two  or more  entries  containing
  3141. methods.
  3142. ``nothing to make''
  3143.     make couldn't find any target to update.
  3144. ``no suffix list.''
  3145.     No suffixes will be recognized by make.
  3146. ``xxx removed''
  3147.     Following a ^C, the file being currently updated has been deleted.
  3148.  
  3149.  
  3150. Bugs:
  3151.  
  3152.     The return status given by MS-DOS commands is not very consistant:  use
  3153. the -i option to overcome this difficulty.
  3154.  
  3155.  
  3156. Portability:
  3157.  
  3158.     The ability to issue a command like a:make .exe:   is an  enhancement.
  3159. So is the use of make.ini.
  3160.  
  3161.  
  3162. See Also:
  3163.  
  3164.     touch.
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.  
  3184.  
  3185.  
  3186.  
  3187. [8] make --------------------------------------- The Berkeley Utilities V1.0
  3188.  
  3189.                                                           Text files browser
  3190.  
  3191. Synopsis:                    more [options] [... files]
  3192.     more  works  on  the  list  of  files  you  entered on  the  command  line
  3193. (wildcards are allowed), or directly on stdin if no argument was given, for
  3194. instance in case of a pipe.
  3195.  
  3196. Description:
  3197.     more is an interactive utility which enables the user  to view one  or
  3198. more files on the screen.
  3199.  
  3200. Options:
  3201.     The following options are available on the command line:
  3202.     -tn       n is an integer, giving the tab size.   By default, n is  8.
  3203.               If n is 0, tabs will not be interpreted.
  3204.     -f        Lines longer than the screen width are not folded.
  3205.     -a        ANSI  escape  sequences  specifying  screen  attributes are  not
  3206.               interpreted.
  3207.  
  3208.     -T        Make tabs visible by giving them a different attribute  (the
  3209.               fourth attribute in the environment variable VATTR).
  3210.     -E        Make  empty  space  (ie  parts  of  the  screen  which  do  not
  3211.               correspond to any text in the file) visible  by giving it  a
  3212.               different attribute (the third attribute in the  environment
  3213.               variable VATTR).
  3214.     -n        Gives  an  n  lines  display  if  your  video  card  allows  it.
  3215.               Currently the values 25, 43 if you have an EGA or VGA  card,
  3216.               and 50 if you have a VGA card are accepted.   By default the
  3217.               current number of lines of your display is used.
  3218.  
  3219.     +line     Start the display at line number line.   Lines are  numbered
  3220.               beginning at 1.
  3221.     -epattern Start  the  display  at  first  occurence  of  this  pattern.
  3222.               pattern  is  a  regular  expression  in  the  style  of  ``ed''.
  3223.               For  more  information,  consult  specific  documentation  about
  3224.               regular expressions.
  3225.     -w        Match only on complete words.
  3226.  
  3227.     -i        No case significance in regular expression matching.
  3228.  
  3229.     Most more commands are unechoed one-character commands with  immediate
  3230. effect.   Some commands are longer,  entered interactively on the  command
  3231. line (the last line of the screen, which also serves as a status line), and
  3232. need a carriage-return (<CR>) before processing.   The last screen line is
  3233. reserved for various messages and statistics, and user input.  It gives the
  3234. name of the displayed file, the percentage currently read and receives the
  3235. <CR>ending commands (during input of such a command, you may edit it  with
  3236. the arrow keys,  <backspace>,  the <Home>  and <End>  keys,  the <Del>  key,
  3237. <Escape> which clears the whole command, and you may switch between insert
  3238. and overwrite mode with the <Ins> key).  The commands available when inside
  3239. more may be sorted into different classes, according to their usage:
  3240.  
  3241.  
  3242.  
  3243.  
  3244. The Berkeley Utilities V1.0 --------------------------------------- more [1]
  3245.  
  3246. Getting on-line help
  3247.     h or F1        Open a ``help window'':   all commands listed below are
  3248.                    briefly described in the two pages of the help window.
  3249. Moving inside a file:
  3250.     Most of these commands may be preceded by an integer argument.
  3251.  
  3252.     <space>        Display the next screenful of the file.
  3253.  
  3254.     f              Idem.
  3255.  
  3256.     <PgDn>         Idem.
  3257.  
  3258.     <CR>           Scroll forward one line.
  3259.  
  3260.     #              Idem.
  3261.  
  3262.     ^U             Scroll forward one half screen.
  3263.  
  3264.     b              Skip backward and display the previous screenful of the
  3265.                    file.
  3266.     <PgUp>         Idem.
  3267.  
  3268.     "              Scroll backward one line.
  3269.     ^D             Scroll backward one half screen.
  3270.  
  3271.     G              Go  to  line  number  n  where n  is  the integer  argument
  3272.                    given before the command.  This line is displayed as the
  3273.                    first line on the screen if there  are enough lines  in
  3274.                    the file to do so.   If n is absent, goes to the end of
  3275.                    the file.
  3276.  
  3277. The following commands take no argument:
  3278.  
  3279.     <Control Home> Go back to beginning of file.
  3280.     <Control End>  Go to end of file.
  3281.  
  3282.     ?  or !        Scroll  laterally  one  column.    This  command  is  only
  3283.                    allowed if the option -f was given on the command line,
  3284.                    or the toggle o (see below) is not set,  i.e.   if long
  3285.                    lines are not folded.
  3286.     <Home>         Go  back  to  the  first  column  (in  case  of  lateral
  3287.                    scrolling).
  3288.  
  3289. Changing file
  3290.     +           If you asked to view several files,  the + command  closes
  3291.                 the current file and displays the nth  next file given  on
  3292.                 the command line.  n is either the argument, or, by default
  3293.                 the next file.
  3294.  
  3295.     :n<CR>      Idem.
  3296.  
  3297.     -           If you asked to view several files,  the - command  closes
  3298.                 the current file and displays the nth previous file  given
  3299.                 on the command line.
  3300. [2] more --------------------------------------- The Berkeley Utilities V1.0
  3301.     :p<CR>      Idem.
  3302.  
  3303.     x           Display  the  list  of  the  files  that  you entered  on  the
  3304.                 command line in a window.   The name of  the current  file
  3305.                 appears highlighted.   You may use the following  commands
  3306.                 to move inside this window:  arrow keys, <Home> and <End>,
  3307.                 <PgUp> and <PgDn>.   Hit <enter>  to display the file whose
  3308.                 name  appears  highlighted.    If  you  change  your mind  and
  3309.                 don't wish any change, just hit <Escape>.
  3310.  
  3311.     :nlist      Be  careful,  the  :n  without  any argument  has a  different
  3312.                 meaning.   This one permits you to change the list of  the
  3313.                 files that you wish to view.  Just enter :n followed by the
  3314.                 new list.  The use of wildcards is allowed.
  3315.  
  3316.     q or :q<CR> Quit more.
  3317.     Q or :Q<CR>
  3318.  
  3319. Searching for regular expressions
  3320.     In order to get the most out of the regular expressions feature, refer
  3321.     to the Appendix.
  3322.     /reg.  exp.<CR> Search forward for reg.  exp..
  3323.  
  3324.     ?reg.  exp.<CR> Search backward for the reg.  exp..
  3325.  
  3326.     n               Search  for  the  next  occurence  of  the  last  regular
  3327.                     expression  entered.     This  command  keeps  the  same
  3328.                     direction of search.
  3329.  
  3330.     N               Search for the the last regular expression entered  in
  3331.                     the reverse direction of search.
  3332.  
  3333.     i               Toggle case significance on searches.
  3334.  
  3335.     w               Toggle match on complete words only in searches.
  3336.     If  found,  the  expression  is  highlighted on  screen  with a  different
  3337.     video  attribute  (the  second  attribute  in  the  environment  variable
  3338.     VATTR;  if  the  regular  expression  has  subexpressions,   they  are
  3339.     themselves highlighted with further attributes taken in sequence  from
  3340.     VATTR).
  3341.  
  3342. Calling system interface
  3343.     :!<CR>        Give control to the shell.
  3344.  
  3345.     :!command<CR> Execute command.
  3346.  
  3347.     v             Call  selected  editor.    This  command  is only  available
  3348.                   if  you  previously  gave  a  value  to  the  environment
  3349.                   variable ``EDITOR'' through the MS-DOS command  ``set'',
  3350.                   for instance:
  3351.                                         set EDITOR=VI.
  3352.                   You may make the editor start on the current line of the
  3353.                   file, if there is such a start option on your editor, by
  3354.                   placing a %d marker in EDITOR. For instance, vi starts on
  3355.                   line 321 of foo if the command vi +321 foo is given;  so
  3356.                   if you use vi, set EDITOR=vi +%d to have it start on the
  3357. The Berkeley UtilitieseV1.0i--------------------------------------- more [3]
  3358.  
  3359. Controlling presentation
  3360.     t Change  tab  size  (to  the  numeric argument  n) n  absent  or 0  means
  3361.       disable tab interpretation.
  3362.     T Make tabs visible by giving them a  different attribute (the  fourth
  3363.       attribute in the environment variable VATTR).
  3364.     o Toggle folding of long lines.
  3365.     a Toggle interpretation of ANSI attribute sequences  in the  displayed
  3366.       file.
  3367.     E Make empty space (ie parts of the screen which do not correspond  to
  3368.       any text in the file) visible by giving it a different attribute (the
  3369.       third attribute in the environment variable VATTR).
  3370.  
  3371.  
  3372.  
  3373.  
  3374.  
  3375.  
  3376.  
  3377.  
  3378.  
  3379.  
  3380.  
  3381.  
  3382.  
  3383.  
  3384.  
  3385.  
  3386.  
  3387.  
  3388.  
  3389.  
  3390.  
  3391.  
  3392.  
  3393.  
  3394.  
  3395.  
  3396.  
  3397.  
  3398.  
  3399.  
  3400.  
  3401.  
  3402.  
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414. [4] more --------------------------------------- The Berkeley Utilities V1.0
  3415.  
  3416.                                                   Move files and directories
  3417.  
  3418.  
  3419. Synopsis:              mv [options] file|dir ... file|dir dir
  3420. or                           mv [options] source target
  3421.     mv  moves  files  or  directories  matched  by  the  pathnames  given  as
  3422. argument.
  3423.  
  3424.  
  3425. Description:
  3426. There are two forms of the command:
  3427.   o short form:   there are only two arguments, and both arguments consist
  3428.     of one file, or both of one directory, or the second argument is a new
  3429.     name.  The first argument is moved over the second (target).
  3430.   o long form:   the last argument is a directory (target)  and all  other
  3431.     arguments are moved to that target directory.
  3432. Watch out when using wild cards (like file.*), as the target must expand to
  3433. at most one name.
  3434.  
  3435.  
  3436. Options:
  3437.  
  3438.     The possible options on the command line are:
  3439.  
  3440.     -r   Allows mv to move (and possibly overwrite) non-empty  directories
  3441.          (if not given, only empty directories are moved or overwritten).
  3442.     -m   When  moving  directories,  merges  the  source  with  the  target
  3443.          (instead of overwriting the target).
  3444.     -v   Gives on stdout a report on moved files.
  3445.     -f   Do  not  ask  confirmation  before  overwriting read-only  files  (by
  3446.          default the authorization of the user is asked).
  3447.     -i   Asks confirmation on the terminal before overwriting any file  or
  3448.          directory.
  3449.     -I   Asks  confirmation  on  the  terminal  before  moving  any  file  or
  3450.          directory.  This option implies the -i option.
  3451.  
  3452.     When the options -i or -I are given, the only answers allowed are:
  3453.  n: continue, do not overwrite or move.
  3454.  q: leave.
  3455.  g: (go) stop asking questions.
  3456.  y: overwrite or move.
  3457.  s: answer valid only for a directory.   Overwrite or move without  asking
  3458.     further confirmations for files or sub-directories of this directory.
  3459.  
  3460.  
  3461. Examples:
  3462.  
  3463.  
  3464.        mv -I c:sources\*.*\*.bak a:
  3465.  
  3466. Moves  all  files  *.bak  in  sub-directories  of  directory  sources   to
  3467. diskette a:, asking confirmation for each file.
  3468.  
  3469.  
  3470.  
  3471. The Berkeley Utilities V1.0 ----------------------------------------- mv [1]
  3472.  
  3473. See Also:
  3474.  
  3475.     cp and rm.
  3476.  
  3477.  
  3478. Portability:
  3479.  
  3480.     the option -r is partly from the BSD version and partly an enhancement.
  3481. The options -m, -v, -i and -I are enhancements.
  3482.  
  3483.  
  3484. Bugs:
  3485.  
  3486.     Does not always work with Novell Netware.   It may be safer to use  cp
  3487. followed by rm.
  3488.  
  3489.  
  3490.  
  3491.  
  3492.  
  3493.  
  3494.  
  3495.  
  3496.  
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502.  
  3503.  
  3504.  
  3505.  
  3506.  
  3507.  
  3508.  
  3509.  
  3510.  
  3511.  
  3512.  
  3513.  
  3514.  
  3515.  
  3516.  
  3517.  
  3518.  
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.  
  3527.  
  3528. [2] mv ----------------------------------------- The Berkeley Utilities V1.0
  3529.  
  3530.                                                                     ``dump''
  3531.  
  3532.  
  3533. Synopsis:                   od [options] [file ... file]
  3534.  
  3535.  
  3536. Description:
  3537.  
  3538.     od dumps the contents of its file argument(s) in one or several formats
  3539. specified by the option arguments (by default, the options  -c and -h  are
  3540. taken).
  3541.  
  3542.  
  3543. Options:
  3544.  
  3545.     The possible options are:
  3546.  
  3547.     -c  Interprets consecutive bytes as ASCII characters.    Non-printable
  3548.         characters are represented according to the same conventions as in
  3549.         the C language.
  3550.     -h  Interpret bytes in unsigned hexadecimal.
  3551.     -b  Interpret bytes in unsigned octal.
  3552.     -d  Interpret 2-byte words in unsigned decimal.
  3553.     -s  Interpret 2-byte words in signed decimal.
  3554.     -o  Interpret 2-byte words in unsigned octal.
  3555.     -x  Interpret 2-byte words in unsigned hexadecimal.
  3556.     -D  Interpret 4-byte words in unsigned decimal.
  3557.     -S  Interpret 4-byte words in signed decimal.
  3558.     -O  Interpret 4-byte words in unsigned octal.
  3559.  
  3560.     -X  Interpret 4-byte words in unsigned hexadecimal.
  3561.     +n  Starts dumping at the nth byte from the beginning of the file.  The
  3562.         number n can be specified in octal (0ddd) or in hexadecimal (0xddd)
  3563.         as well as in decimal.   The running  count of  characters in  the
  3564.         dump output will be given in the  same format  (decimal,  octal or
  3565.         hexadecimal) as the format specified here.
  3566.     -r  Swap the 2 bytes before interpreting 2-byte words.
  3567.  
  3568.     -R  Swap the two 2-byte words before interpreting 4-byte words.
  3569.  
  3570.  
  3571. Portability:
  3572.  
  3573.     The use of different video attributes to  highlight key  parts of  the
  3574. output is an enhancement.
  3575.     The options -D, -S, -O, -X, -r, -R are also enhancements.
  3576.  
  3577.  
  3578.  
  3579.  
  3580.  
  3581.  
  3582.  
  3583.  
  3584.  
  3585. The Berkeley Utilities V1.0 ----------------------------------------- od [1]
  3586.  
  3587.                                      merge files as columns of a single file
  3588.  
  3589.  
  3590. Synopsis:                      paste [-dlist] [files]
  3591. or                            paste -s  [-dlist [file]]
  3592.     paste merges the lines of the files entered as arguments according  to
  3593. the options specified on the command line.   If no files are specified  or
  3594. the file name -, paste works on the standard input.
  3595.  
  3596.  
  3597. Description:
  3598.     paste merges corresponding lines of each file  separating them in  the
  3599. result with a selected character,  or concatenates subsequent  lines of  a
  3600. single file (-s option).   paste sends the result on the standard  output.
  3601. By default, the binding character is the tab character \t, unless option -d
  3602. has been given (see the description of the -d option below).   Whether the
  3603. option -d  has been given or not, the lines from the last file are  always
  3604. followed by the character \n (newline).  When the option -s has been given,
  3605. only the last line of the file is followed by a newline, unless  a newline
  3606. also appears in the list given with the -d option.
  3607.  
  3608. The option d:
  3609.     -dlist list  is  a  list  of  characters  to  use  as  the  concatenation
  3610.            character.   This list is used circularly, i.e.   is reused when
  3611.            exhausted.   The list is also restarted for every new cycle  on
  3612.            the input files to give a line of output, if the option -s  was
  3613.            not given.   As mentioned above,  the lines from the last  file
  3614.            will be followed by a newline, not by a character from the list.
  3615.            The list may contain special characters encoded as follows:  \n
  3616.            (newline), \t (tab), \\ (backslash) and \0 (null).  As usual, an
  3617.            argument containing characters which have a special meaning for
  3618.            DOS must be quoted by "'s.
  3619.  
  3620.  
  3621. Examples:
  3622.  
  3623.     C:\>cat junk
  3624.     love apples
  3625.     hate raisins
  3626.     eat  oranges
  3627.     C:\>cat junk.bak
  3628.     apples 12 \kilos
  3629.     raisins 14 \pounds
  3630.     oranges 23 \units
  3631.     C:\>paste junk junk.bak
  3632.     love apples     apples 12 \kilos
  3633.     hate raisins    raisins 14 \pounds
  3634.     eat  oranges    oranges 23 \units
  3635.  
  3636.  
  3637. See Also:
  3638.     cut.
  3639.  
  3640.  
  3641.  
  3642. The Berkeley Utilities V1.0 -------------------------------------- paste [1]
  3643.  
  3644.                                           Redirects error output of commands
  3645.  
  3646.  
  3647. Synopsis:                        rederr file command
  3648.  
  3649.     It is possible in MS-DOS to redirect the  standard (stdout) output  of
  3650. commands  with  the  >  operator,  but  MS-DOS  does not  provide any  way  to
  3651. redirect the error (stderr) output.  This program solves the problem.
  3652.  
  3653.     The first argument is the name of the file where you want to  redirect
  3654. the error output, and the following argument(s) is the command (given with
  3655. its arguments, if it has any) whose error output you want to redirect.
  3656.  
  3657.  
  3658. Notes:
  3659.  
  3660.     This command is not available in UNIX, but its function is.
  3661.  
  3662.  
  3663.  
  3664.  
  3665.  
  3666.  
  3667.  
  3668.  
  3669.  
  3670.  
  3671.  
  3672.  
  3673.  
  3674.  
  3675.  
  3676.  
  3677.  
  3678.  
  3679.  
  3680.  
  3681.  
  3682.  
  3683.  
  3684.  
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.  
  3692.  
  3693.  
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699. The Berkeley Utilities V1.0 ------------------------------------- rederr [1]
  3700.  
  3701.                                                 Remove files and directories
  3702.  
  3703.  
  3704. Synopsis:                   rm [options] file1 ... filen
  3705.  
  3706.     rm removes files or directories.
  3707.  
  3708.  
  3709. Description:
  3710.  
  3711.     Wild-cards (like file.*) are allowed to specify the arguments.   Before
  3712. overwriting a read-only file, rm asks for confirmation;  also rm will  not
  3713. remove a non-empty directory unless the option -r has been given.
  3714.  
  3715.  
  3716. Options:
  3717.  
  3718.     The possible options on the command line are:
  3719.  
  3720.     -r   Recursively remove the contents of sub-directories.
  3721.     -v   Write on stdout a report on removed files.
  3722.     -f   Do  not  ask  confirmations  before  overwriting read-only  files  or
  3723.          directories.
  3724.     -i   Ask  confirmation  from  the  terminal  before removing  any file  or
  3725.          directory.
  3726.     The valid answers to questions are:
  3727.  n: continue, do not remove.
  3728.  q: leave.
  3729.  g: (go) stop asking questions.
  3730.  y: remove.
  3731.  s: answer  valid  only  for  directories.    Remove  without  asking  further
  3732.     confirmations for files or sub-directories in this directory.
  3733.  
  3734.  
  3735. Examples:
  3736.  
  3737.  
  3738.  
  3739.     C:>rm -i *.*
  3740.  
  3741. A safer way to clean up than ``del *.*''.
  3742.  
  3743.  
  3744. Portability:
  3745.  
  3746.     The option -r  comes from Berkeley's unix version, and the options  -v
  3747. and -i are enhancements.
  3748.  
  3749.  
  3750. See Also:
  3751.  
  3752.     ls cp, mv.
  3753.  
  3754.  
  3755.  
  3756. The Berkeley Utilities V1.0 ----------------------------------------- rm [1]
  3757.  
  3758.                                                                Stream editor
  3759.  
  3760.  
  3761.  
  3762. Synopsis:           sed [-n] [-e script] [-f script file] [files]
  3763.  
  3764.     sed  copies  the  files  entered  as  arguments  to  the  standard  output
  3765. according to the commands given on the command line  (option -e), or in  a
  3766. file script (option -f).  If there is no -f option and only one -e option,
  3767. the flag -e is optional.
  3768.  
  3769.  
  3770. Description:
  3771.  
  3772.     Normally, sed cyclically reads a line of input and copies it into  the
  3773. pattern space.  Every command is then executed, if its address matches the
  3774. pattern space.   At the end of the script, sed copies the pattern space on
  3775. the standard output before deleting it.
  3776.     Some commands also use a hold space, where they save all or part of the
  3777. pattern space for a possible later use.
  3778.     Regular  expressions  are  used  to  specify  addresses  (lines)  or,  for
  3779. some commands,  parts of lines,  as in the s command.   If  you want  more
  3780. information about the use of regular expressions, consult the Appendix.
  3781.  
  3782.  
  3783. Options:
  3784.  
  3785.     The only available option on the command line is:
  3786.  
  3787.     -n Suppress the default output of the pattern space at the end of each
  3788.        cycle.
  3789.  
  3790.  
  3791. Adresses:
  3792.  
  3793.     An address is either an integer giving  the number of  the input  line
  3794. concerned or a ``context'' address, i.e.  a regular expression in the style
  3795. of ed but modified as follows:
  3796.  
  3797.     The regular expression may be constructed as \?RE?, where ?  represents
  3798. any character.  In order to get this character without its special meaning
  3799. inside  of  the  expression,  you  can  just  escape  it  with  a  \.    This
  3800. construction is exactly identical to /RE/.
  3801.     A period (.)   matches any character except the ending newline of  the
  3802. pattern space.
  3803.     A command with no addresses selects every pattern space.
  3804.     A command with one address selects  every pattern  space that  matches
  3805. this address.
  3806.     A command with two addresses selects the range from the first  pattern
  3807. space that matches the first address through the pattern space that matches
  3808. the second address, and again till the end of the last file.
  3809.     The  escape  sequence  `\n'  matches  a newline  embedded  in the  pattern
  3810. space.
  3811.  
  3812.  
  3813. The Berkeley Utilities V1.0 ---------------------------------------- sed [1]
  3814.  
  3815. Commands:
  3816.  
  3817.     It is possible to group several commands under one address with a pair
  3818. of curly brackets:   {}.   Commands are applied on the  lines selected  by
  3819. the specified addresses.   In order to have them applied to the lines  not
  3820. selected, just prefix the command with !.  This is also allowed for groups
  3821. of commands.
  3822.     The  following  commands  are  preceded  by  their  maximum  number  of
  3823. permissible addresses in parentheseses.
  3824.     The argument <text> of the first three commands may consist of several
  3825. lines, in which case each line, except the last one, must end with \.
  3826.  
  3827.  
  3828. (1) a\     Appends <text> after the pattern space.   The result appears on
  3829.     <text> the output just before reading the next input line.
  3830.  
  3831. (2) c\     Deletes the contents of the pattern space,  appends <text>  and
  3832.     <text> copies it to the output, after the pattern specified by zero or
  3833.            one address, or at the end of a two-addresses range.  Starts the
  3834.            next cycle immediately.
  3835.  
  3836. (1) i\     Places <text> immediately on the output.
  3837.     <text>
  3838.  
  3839.     The following commands take a file name as argument:  this name must be
  3840. preceded by exactly one blank and should terminate the line.   There can't
  3841. be more than ten files opened in write access at the same time and all such
  3842. files are opened before processing.
  3843.  
  3844.  
  3845. (2) rrfile Reads the contents of rfile and places them on the output  just
  3846.            before reading the next input line.
  3847.  
  3848. (2) wwfile Appends the contents of the pattern space to wfile.
  3849.  
  3850.     The s command also has a file name as argument among its four optional
  3851.  
  3852. flags:
  3853.  
  3854. (2) s/Reg.Exp./subst/flags Replaces occurrences of the regular expressions
  3855.                            in the pattern space with the string subst.  You
  3856.                            may use any character instead of /.  One or more
  3857.                            of  the  following  flags  may  be added  to the  s
  3858.                            command:
  3859.                          n n  is  an  integer  in  the  range  1  -   512.
  3860.                            The  substitution  will  only  occur  on  the  nth
  3861.                            occurrence of the regular expression.
  3862.                          g Global:    The  substitution  will  occur  on  all
  3863.                            occurrences of the regular expression.
  3864.                          p Prints the pattern space only if a substitution
  3865.                            occurred.
  3866.                    w wfile Appends  the  contents  of  the  pattern  space  to
  3867.                            wfile, only if a substitution occurred.
  3868.  
  3869. [2] sed ---------------------------------------- The Berkeley Utilities V1.0
  3870.  
  3871. Other commands:
  3872.  
  3873. (2) b label            Branches to the :   command bearing label.   If  no
  3874.                        label is specified, branch to the end of the script.
  3875. (2) d                  Deletes the contents of the pattern space.   Starts
  3876.                        immediately the next cycle.
  3877. (2) D                  Deletes the contents of the pattern space,  through
  3878.                        the  first  newline.    Starts  immediately  the  next
  3879.                        cycle.
  3880. (2) g                  Replaces the contents of the pattern  space by  the
  3881.                        contents of the hold space.
  3882. (2) G                  Appends  the  contents  of  the  hold  space  to  the
  3883.                        contents of the pattern space.
  3884. (2) h                  Replaces  the  contents  of  the  hold  space  by  the
  3885.                        contents of the pattern space.
  3886. (2) H                  Appends  the  contents  of  the  pattern  space to  the
  3887.                        contents of the hold space.
  3888.  
  3889. (2) l                  Copies  the  contents  of  the  pattern  space   to
  3890.                        the   standard   output   in   an   unambiguous   form:
  3891.                        non-printing  characters  are  represented  by  the
  3892.                        conventionnal  ``caret-letter  ''  sequence.     Long
  3893.                        lines are folded.
  3894. (2) n                  Prints  the  contents  of  the  pattern  space  on  the
  3895.                        standard output.  Deletes the pattern space and gets
  3896.                        the next line of input.
  3897.  
  3898. (2) N                  Appends the next line of input to the pattern space
  3899.                        with an embedded newline.
  3900. (2) p                  Prints  the  contents  of  the  pattern  space  on  the
  3901.                        standard output.
  3902.  
  3903. (2) P                  Prints the contents of the pattern space through the
  3904.                        first newline on the standard output.
  3905. (1) q                  Quit sed.
  3906.  
  3907. (2) tlabel             Conditional branch to the :   command bearing label
  3908.                        if  a  substitution  occurred  since  the  most  recent
  3909.                        reading of input line or the last execution of a  t
  3910.                        command.   If label is not specified, branch to the
  3911.                        end of the script.
  3912. (2) x                  Exchange the contents of the pattern space and  the
  3913.                        contents of the hold space.
  3914.  
  3915. (2) y/string1/string2/ Replaces all occurrences of characters that  belong
  3916.                        to  string1  with  the  corresponding  character  in
  3917.                        string2.  Both strings must have the same length.
  3918. (1) =                  Prints on the standard output the current input line
  3919.                        number.
  3920.  
  3921. (0) :label             This command doesn't do anything:   it only bears a
  3922.                        label for the b or t commands.
  3923.  
  3924.  
  3925.  
  3926. The Berkeley Utilities V1.0 ---------------------------------------- sed [3]
  3927.  
  3928. (2) {                  Execute  all  commands  that  follow  {  through  the
  3929.                        corresponding (balanced) } if the given address(es)
  3930.                        select(s) the pattern space.
  3931.     A script line beginning with a # is a comment line.   If this line  is
  3932. the first line in the script and if the # is immediately followed by  a n,
  3933. the default output of the pattern space will be  suppressed, as in the  -n
  3934. option of the command line.
  3935.  
  3936.  
  3937. See Also:
  3938.  
  3939.     ed, awk, diff, grep and the Appendix on regular expressions.
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958.  
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964.  
  3965.  
  3966.  
  3967.  
  3968.  
  3969.  
  3970.  
  3971.  
  3972.  
  3973.  
  3974.  
  3975.  
  3976.  
  3977.  
  3978.  
  3979.  
  3980.  
  3981.  
  3982.  
  3983. [4] sed ---------------------------------------- The Berkeley Utilities V1.0
  3984.  
  3985.                                                                   Sort files
  3986.  
  3987.  
  3988. Synopsis:         sort [options] [+coldsc[-coldsc]] [file ... file]
  3989.  
  3990.     sort works on the files entered on the command line, sorts them line by
  3991. line and sends the result to stdout.  If no files arguments are given or if
  3992. - was given as an argument, sort uses stdin.
  3993.  
  3994.  
  3995. Description:
  3996.  
  3997.     sort works on the fields specified on the command  line by the  column
  3998. descriptors (coldsc) m.n, where m represents a number of fields  delimited
  3999. by white space to skip from the beginning  of the line and  n a number  of
  4000. characters to skip further from the beginning of  the field m.   A  coldsc
  4001. preceded by + (+m.n) indicates the beginning  of a  range of columns  that
  4002. sort will use for comparisons and  coldsc preceded by  - (-m.n)  indicates
  4003. the end of the range.   There may  be several descriptor  pairs +m.n  -m.n
  4004. specifying sorting for several ranges.  The ranges given first are the most
  4005. significant; if a +coldsc is given alone (without any -coldsc), the  range
  4006. goes to the end of the line.   By default, sort  sorts on the whole  line.
  4007. The following options are available on the command line:
  4008.  
  4009.     -c     Checks whether the file is already sorted.  If it is, doesn't do
  4010.            anything, else sends a message.
  4011.     -m     Each argument file must be sorted, sort just merges them.
  4012.     -ofile file will be used instead of stdout.  The file is allowed to be
  4013.            the same as one of the argument files.
  4014.     -Tdir  The  temporary  files  created  by  sort during  its  work will  be
  4015.            written in the directory dir.
  4016.     -tx    Changes the fields delimiter to the character x (instead of the
  4017.            default:  whitespace, i.e.  blank, tab and newline).
  4018.  
  4019. Each of the seven following options may be added to a column descriptor and
  4020. thus affect only the corresponding fields:
  4021.  
  4022.     -u   If  several  lines  are  found  identical for  the concerned  fields,
  4023.          sort will output only one of them.
  4024.     -b   Ignore leading blanks when comparing fields.
  4025.     -d   Use ``dictionary'' order, i.e.   only letters, digits and  blanks
  4026.          will be significant in comparisons.
  4027.     -f   Use  a  collating  sequence  where  each  lower-case  letter   is
  4028.          immediately followed by the corresponding upper-case letter:   aA
  4029.          bB cC....
  4030.  
  4031.     -i   Lines with characters whose ASCII code doesn't belong to the range
  4032.          32-126 will be appended to the output file.
  4033.     -n   A numeric string is sorted according to numerical ordering.   This
  4034.          option implies option -b.
  4035.  
  4036.     -r   Reverse sorting order.
  4037.  
  4038.  
  4039.  
  4040. The Berkeley Utilities V1.0 --------------------------------------- sort [1]
  4041.  
  4042. Examples:
  4043.  
  4044.     Suppose we have the file ``fruits'' with the following contents:
  4045.  
  4046.       C:>cat fruits
  4047.         apples          10 K
  4048.         apricots         3 K
  4049.         kiwis            2 K
  4050.         raspberries      5 K
  4051.         pears            7 K
  4052.         bananas          4 K
  4053.  
  4054. Let us have a look at the output of the following commands:
  4055.  
  4056.       C:>sort fruits | tee fruits.t
  4057.         apricots         3 K
  4058.         bananas          4 K
  4059.         raspberries      5 K
  4060.         kiwis            2 K
  4061.         pears            7 K
  4062.         apples          10 K
  4063.       C:>sort +1 -b fruits
  4064.         kiwis            2 K
  4065.         apricots         3 K
  4066.         bananas          4 K
  4067.         raspberries      5 K
  4068.         pears            7 K
  4069.         apples          10 K
  4070.  
  4071. Suppose a second file ``vegetables'' is already sorted:
  4072.  
  4073.       C:>cat vegetables
  4074.         artichokes       2 K
  4075.         carrots          5 K
  4076.         leeks            1 K
  4077.       C:>sort -m fruits.t vegetables
  4078.         apricots         3 K
  4079.         artichokes       2 K
  4080.         bananas          4 K
  4081.         carrots          5 K
  4082.         raspberries      5 K
  4083.         kiwis            2 K
  4084.         leeks            1 K
  4085.         pears            7 K
  4086.         apples          10 K
  4087.  
  4088.  
  4089. Notes:
  4090.  
  4091.     This program is greatly superior to MS-DOS's SORT.
  4092.  
  4093.  
  4094.  
  4095.  
  4096.  
  4097. [2] sort --------------------------------------- The Berkeley Utilities V1.0
  4098.  
  4099.                                             Split a file into smaller pieces
  4100.  
  4101.  
  4102. Synopsis:                  split [- number [file [name]]]
  4103.  
  4104.     split splits the given argument file in  pieces which  have the  given
  4105. number of lines specified on the command line.  By default, split takes its
  4106. input from stdin if no filename has been given  and the maximum number  of
  4107. lines per piece is 1000 if no number has been given.
  4108.  
  4109.  
  4110. Description:
  4111.  
  4112.     The names given to the pieces  are built from  the name  given on  the
  4113. command line to which split adds the suffix  aa, then ab,  ac, ...  and so
  4114. on in alphabetical order.   If no name has been  specified, split uses  by
  4115. default the name x.
  4116.  
  4117.  
  4118.  
  4119.  
  4120.  
  4121.  
  4122.  
  4123.  
  4124.  
  4125.  
  4126.  
  4127.  
  4128.  
  4129.  
  4130.  
  4131.  
  4132.  
  4133.  
  4134.  
  4135.  
  4136.  
  4137.  
  4138.  
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.  
  4148.  
  4149.  
  4150.  
  4151.  
  4152.  
  4153.  
  4154. The Berkeley Utilities V1.0 -------------------------------------- split [1]
  4155.  
  4156.                                                    Display the end of a file
  4157.  
  4158.  
  4159. Synopsis:               tail [+|- [number]] [options] [file]
  4160.  
  4161.     tail writes on (stdout) the file entered as argument, starting at  the
  4162. specified location.  If no file is specified, tail uses stdin.
  4163.  
  4164.  
  4165. Description:
  4166.  
  4167.     Depending on the sign preceding number, the display will start at some
  4168. distance from the beginning of the file (+number) or  from the end of  the
  4169. file (-number).   number represents an offset which by default is a number
  4170. of lines;  it represents a number of characters if  option -c  is present.
  4171. The option -r  is special, and incompatible with the option -c.   tail  -r
  4172. displays the lines in the opposite order to the initial file.
  4173.     If no number is given, the default is  10 lines,  unless option -r  is
  4174. present, whence the default consists of displaying  the whole file  upside
  4175. down.
  4176.  
  4177.  
  4178. Bugs:
  4179.  
  4180.     Cannot show a tail of more than 55K.
  4181.  
  4182.  
  4183.  
  4184.  
  4185.  
  4186.  
  4187.  
  4188.  
  4189.  
  4190.  
  4191.  
  4192.  
  4193.  
  4194.  
  4195.  
  4196.  
  4197.  
  4198.  
  4199.  
  4200.  
  4201.  
  4202.  
  4203.  
  4204.  
  4205.  
  4206.  
  4207.  
  4208.  
  4209.  
  4210.  
  4211. The Berkeley Utilities V1.0 --------------------------------------- tail [1]
  4212.  
  4213.                                               pipe connection and derivation
  4214.  
  4215.  
  4216. Synopsis:                   tee [options] file [... file]
  4217.  
  4218.     tee diverts to all argument files  the output of  a pipe  (as well  as
  4219. transmitting it faithfully to stdout).
  4220.  
  4221.  
  4222. Description:
  4223.  
  4224.     The possible options are:
  4225.  
  4226.     -i   Ignore interrupts.
  4227.     -a   If one of the output files already exists, append data to the end
  4228.          of the file rather than overwrite the file.
  4229.     the first option, which is useful under UNIX, does not make much sense
  4230. under MS-DOS, since pipes are executed sequentially and not asynchronously.
  4231.  
  4232.  
  4233. Examples:
  4234.  
  4235.  
  4236.  
  4237.     ls -tT *.c | tee abc | more
  4238.  
  4239. This  redirects  the  output  of  ls to  more  where you  can browse  it,  and
  4240. simultaneously makes a copy in the file abc, which you can consult at your
  4241. leisure later on.
  4242.  
  4243.  
  4244.  
  4245.  
  4246.  
  4247.  
  4248.  
  4249.  
  4250.  
  4251.  
  4252.  
  4253.  
  4254.  
  4255.  
  4256.  
  4257.  
  4258.  
  4259.  
  4260.  
  4261.  
  4262.  
  4263.  
  4264.  
  4265.  
  4266.  
  4267.  
  4268. The Berkeley Utilities V1.0 ---------------------------------------- tee [1]
  4269.  
  4270.                                                      updates files timestamp
  4271.  
  4272.  
  4273. Synopsis:              touch [options] [-date] file [... file]
  4274.  
  4275.     touch gives the current date and time  to the files  specified on  the
  4276. command line.
  4277.  
  4278.  
  4279. Description:
  4280.  
  4281. touch can work on empty files.  Furthermore, if you ask touch to work on a
  4282. non-existent file, it will ask you if you want to create this file.
  4283. If no date or agefile (see below)  has been specified,  touch updates  its
  4284. arguments with the current date and time, otherwise, touch interprets  the
  4285. given date according to the following format:
  4286.     [[[YY]MM]DD]hhmm[.ss]
  4287. with the following meaning:
  4288.  
  4289.   o hh:  Hour, compulsory.
  4290.  
  4291.   o mm:  Minutes, compulsory.
  4292.  
  4293.   o ss:  Seconds, optional; by default:  0.
  4294.   o DD: Day, optional; by default:  current day.   If no day is given,  no
  4295.     month or year can be specified.
  4296.  
  4297.   o MM: Month (1 = January, 2 =  February, ...  12 = December),  optional;
  4298.     by default:   current month.   If no month is  given,  no year can  be
  4299.     specified.
  4300.   o YY: Year (counted above 1900), optional; by default:  current year.
  4301.  
  4302.  
  4303. Options:
  4304.  
  4305.     The following options are available on the command line:
  4306.     -c         Create a new file without asking for a confirmation.
  4307.     -f agefile Take the date as being equal to that of given agefile.
  4308.     -i         Ask for a confirmation before touching any file.
  4309.     -r         Allow touch to work recursively in directories.
  4310.     -v         Write on stdout a report on touched files, including  their
  4311.                initial date.
  4312.  
  4313.  
  4314. Notes:
  4315.  
  4316.     UNIX internally counts seconds starting with 1970.
  4317.     MS-DOS internally counts seconds starting with 1980.
  4318.  
  4319.  
  4320.  
  4321.  
  4322.  
  4323.  
  4324.  
  4325. The Berkeley Utilities V1.0 -------------------------------------- touch [1]
  4326.  
  4327.                                                    Translate stdin to stdout
  4328.  
  4329. Synopsis:                  tr [options] string1 [string2]
  4330.     tr takes its input from stdin, replaces characters occurring in string1
  4331. by  the  corresponding  characters  in  string2,  with  possible  variations,
  4332. and writes the result on stdout.    This is  useful for  some simple  file
  4333. transformations (see examples below).
  4334.  
  4335. Description:
  4336.     string1 and string2 both specify a character set as follows:
  4337.   - if string2 is too short its last character is replicated.
  4338.   - in  either  string  character  ranges  in  the  form  a-z  are  accepted
  4339.     (specifying characters between a and z in the ASCII order)
  4340.   - to specify the characters - or \ you must escape them by preceding them
  4341.     with a \.
  4342.   - the following standard "C" notation is recognized:
  4343.   o \nnn specifies the character of code octal nnn.
  4344.   o \xnn specifies the character of code hexadecimal nn.
  4345.  
  4346.   o \n specifies the character ``newline''.
  4347.   o \t specifies the character ``tab''.
  4348.   o \b specifies the character ``backspace''.
  4349.  
  4350.   o \r specifies the character ``carriage return''.
  4351.  
  4352. Options:
  4353.  
  4354.     There are three options which modify the translation:
  4355.  
  4356.     -d Delete characters in string1 (do not use string2).
  4357.     -s (squeeze)  Output  only  one  of  a  sequence of  identical  characters
  4358.        obtained  from  string2  (which  may  correspond  to  one  or  several
  4359.        different characters from string1).
  4360.     -c string1  is replaced by its complement set (amongst all  characters
  4361.        with codes 0 to 255) taken in ascending order.
  4362.  
  4363. Examples:
  4364.  
  4365.   - to look at the text in file1 in uppercase, type
  4366.     tr a-z A-Z <file1
  4367.   - copy all words from file1 to file2,  one per  line (here a  word is  a
  4368.     sequence of alphabetic characters):
  4369.     tr -cs A-Za-z \n <file1 >file2
  4370.     this works by translating all characters not (option -c) alphabetic to
  4371.     newlines and then by ``squeezing'' (option - s) consecutive newlines to
  4372.     one newline.
  4373.  
  4374.   - display file, omitting from the display all control characters (codes 1
  4375.     to 37 octal):
  4376.  
  4377.  
  4378.     tr -d \001-\037 <file
  4379.  
  4380.  
  4381.  
  4382. The Berkeley Utilities V1.0 ----------------------------------------- tr [1]
  4383.  
  4384. Bugs:
  4385.  
  4386.     Mimicking  its  UNIXcounterpart,  tr  will  delete all  ASCII NULL  (\000)
  4387. from its input and will not handle them in string1 or string2
  4388.  
  4389.  
  4390. See Also:
  4391.  
  4392.     ed, sed.
  4393.  
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.  
  4420.  
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426.  
  4427.  
  4428.  
  4429.  
  4430.  
  4431.  
  4432.  
  4433.  
  4434.  
  4435.  
  4436.  
  4437.  
  4438.  
  4439. [2] tr ----------------------------------------- The Berkeley Utilities V1.0
  4440.  
  4441.                        Compresses runs of tabs and blanks in character files
  4442.  
  4443.  
  4444. Synopsis:                  unexpand [-tabsize][-a]file(s)
  4445.  
  4446.     Compresses initial runs of tabs and blank  characters to optimal  such
  4447. sequences in each line of the character files given as argument and prints
  4448. the result to the console (stdout).  If no file arguments are given or one
  4449. of them is ``-'' the corresponding input is taken from the console (stdin).
  4450.  
  4451.  
  4452. Description:
  4453.  
  4454.     By default tab stops are every 8 characters; if the option -tabsize is
  4455. given, they are instead every tabsize characters.
  4456.     By default only initial runs of blanks and spaces  are optimized.   If
  4457. the option -a is given,  all such runs  are optimized even  if they  don't
  4458. start a line.
  4459.  
  4460.  
  4461.  
  4462.  
  4463.  
  4464.  
  4465.  
  4466.  
  4467.  
  4468.  
  4469.  
  4470.  
  4471.  
  4472.  
  4473.  
  4474.  
  4475.  
  4476.  
  4477.  
  4478.  
  4479.  
  4480.  
  4481.  
  4482.  
  4483.  
  4484.  
  4485.  
  4486.  
  4487.  
  4488.  
  4489.  
  4490.  
  4491.  
  4492.  
  4493.  
  4494.  
  4495.  
  4496. The Berkeley Utilities V1.0 ----------------------------------- unexpand [1]
  4497.  
  4498.                                              Weed out or find repeated lines
  4499.  
  4500.  
  4501. Synopsis:             uniq [options] [input file[output file]]
  4502.  
  4503.  
  4504. Description:
  4505.  
  4506.     uniq writes on the output file (default stdout) only one of a sequence
  4507. of identical lines found in the input file.
  4508.  
  4509.  
  4510. Options:
  4511.  
  4512.     The possible options are:
  4513.  
  4514.     -u  Only output unique (non-repeated) lines.
  4515.     -d  Only output repeated lines.
  4516.     -c  Put  in  front  of  each  output  line  the  number of  times  it  was
  4517.         repeated.
  4518.     -n  Skip n whitespace-delimited fields at the beginning of lines before
  4519.         comparing them for identity.
  4520.     +n  Skip  n  characters  before  comparing  lines.     This  option  can
  4521.         be  combined  with  the  previous  one,  fields  are  skipped  before
  4522.         characters.
  4523.  
  4524.  
  4525. Examples:
  4526.  
  4527.  
  4528.  
  4529.     tr -cs A-Za-z \n <document | sort | uniq -c
  4530.  
  4531. gives on stdout the list alphabetically sorted  of all  words in the  file
  4532. document, each given once preceded by its number of occurrences.
  4533.  
  4534.  
  4535. See Also:
  4536.  
  4537.     sort, comm.
  4538.  
  4539.  
  4540.  
  4541.  
  4542.  
  4543.  
  4544.  
  4545.  
  4546.  
  4547.  
  4548.  
  4549.  
  4550.  
  4551.  
  4552.  
  4553. The Berkeley Utilities V1.0 --------------------------------------- uniq [1]
  4554.  
  4555.                                                        Count words and lines
  4556.  
  4557.  
  4558. Synopsis:                   wc [options] file [... file]
  4559.  
  4560.     wc counts characters, words or lines of the file arguments.
  4561.  
  4562.  
  4563. Description:
  4564.  
  4565.     If no file argument or the  argument ``-''  has been  given,  wc works
  4566. in stdin.
  4567.  
  4568.  
  4569. Options:
  4570.  
  4571.     The possible options are:
  4572.  
  4573.     -c   Count characters.
  4574.     -w   Count words.
  4575.     -l   Count lines.
  4576.  
  4577.     If  none  of  these  options  has been  given,  all three  are  considered
  4578. active.  If there is more than one file argument, wc also gives a total for
  4579. all the files.
  4580.  
  4581.  
  4582.  
  4583.  
  4584.  
  4585.  
  4586.  
  4587.  
  4588.  
  4589.  
  4590.  
  4591.  
  4592.  
  4593.  
  4594.  
  4595.  
  4596.  
  4597.  
  4598.  
  4599.  
  4600.  
  4601.  
  4602.  
  4603.  
  4604.  
  4605.  
  4606.  
  4607.  
  4608.  
  4609.  
  4610. The Berkeley Utilities V1.0 ----------------------------------------- wc [1]
  4611.  
  4612.                                    Extract character strings from C programs
  4613.  
  4614.  
  4615. Synopsis:                  xstr [options] file [... file]
  4616.  
  4617.     xstr works on the C source  files given  as arguments  on the  command
  4618. line.
  4619.  
  4620.  
  4621. Description:
  4622.  
  4623.     xstr reads a C source file, extracts all character strings from it and
  4624. gathers them to a file named by default x.c.   Each string appears in  x.c
  4625. only once, whatever its actual number of occurences in the C source files.
  4626. Strings appear in x.c in lines of the form char Sxxxx[]="..." , where xxxx
  4627. is a 4-digit integer, and a file  x.h is  also created with  corresponding
  4628. declarations  of  the  form  extern  char  Sxxxx[];.   The  C  source file  is
  4629. rewritten to a file having the same name, but with a suffix x added to the
  4630. extension (e.g., given a file a.c, xstr will write a file a.cx).   In this
  4631. new file, xstr will have replaced character strings  by references of  the
  4632. form Sxxxx and added the directive "#include x.h".
  4633.  
  4634.  
  4635. Options:
  4636.  
  4637.     The possible options on the command line are:
  4638.     -c     Leave the character strings in comments besides Sxxxx references
  4639.            in the new source files output by xstr.
  4640.     -oname Use name instead of x as a prefix of the files x.c and x.h.
  4641.     -r     This  "restring"  option  reinserts  character  strings  in  files
  4642.            output by a previous call to xstr reading them from x.c.  Hence
  4643.            this option will only work if source  files are  the output  of
  4644.            xstr.   This option can be combined with the option -c in order
  4645.            to suppress comments from files output  by a  previous call  to
  4646.            xstr  -c.    It  can  also  be combined  with -o  in  order to  use
  4647.            another file than x.c to get the strings from.
  4648.     xstr can be used to survey and normalize the set of strings  appearing
  4649. in a set of C source files, in particular  to translate them into  another
  4650. language.   It is useful anyway since it  reduces the size  of the  object
  4651. files by making sure that no string is repeated twice.
  4652.  
  4653.  
  4654.  
  4655.  
  4656.  
  4657.  
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663.  
  4664.  
  4665.  
  4666.  
  4667. The Berkeley Utilities V1.0 --------------------------------------- xstr [1]
  4668.  
  4669. Examples:
  4670.  
  4671.     C:>cat test.c
  4672.     main(){printf("Hello, world!");}
  4673.     C:>xstr test.c
  4674.     writing test.cx ...
  4675.     writing x.h
  4676.     writing x.c
  4677.     C:>cat test.cx
  4678.     #include "x.h"
  4679.     main(){printf(S0000);}
  4680.     C:>cat x.h
  4681.     extern char S0000[];
  4682.     C:>cat x.c
  4683.     char S0000[]="Hello, world!";
  4684.     C:>ed -s x.c
  4685.     s/Hello, world/Bonjour, le monde/
  4686.     w
  4687.     q
  4688.     C:>xstr -r test.cx
  4689.     reading x.c
  4690.     writing test.cxx ...
  4691.     writing x.h
  4692.     writing x.c
  4693.     C:>cat test.cxx
  4694.     main(){printf("Bonjour, le monde!");}
  4695. This example shows how in principle xstr can be used to translate messages,
  4696. particularly with repetitions.   In addition,  if the file  x.c output  by
  4697. the first call to xstr is kept, the production of a French version  can be
  4698. largely automated as follows:  Apply xstr to test.c as above, translate x.c
  4699. to French and rename it test.f, sorting it with the command:
  4700.     sort x.c -o test.f
  4701. Then write a makefile containing the methods to use to (re)-make a  French
  4702. version:
  4703.             xstr test.c
  4704.             cp test.f x.c
  4705.             xstr -r test.cx
  4706.             msc $(CFLAGS) test.cxx;
  4707. these will be enough for any modification of test.c which does not  modify
  4708. the  number  of  strings  or  the  order in  which they  appear.    Otherwise,
  4709. reexecute:
  4710.     xstr test.c
  4711.     sort x.c -o x.c
  4712. And then compare x.c and test.f:  most of the time, there will be but a few
  4713. strings to insert and to delete in test.f.  The string numbers will then be
  4714. false, but can be corrected by executing:
  4715.  
  4716.     awk -f renum test.f > x.f
  4717.     mv x.f test.f
  4718. where renum is the following awk program:
  4719.     {print substr($0,1,6) sprintf("%04d",NR-1) substr($0,11,length($0)-10)}
  4720.  
  4721.  
  4722.  
  4723.  
  4724. [2] xstr --------------------------------------- The Berkeley Utilities V1.0
  4725.  
  4726. See Also:
  4727.  
  4728.     make, awk.
  4729.  
  4730.  
  4731.  
  4732.  
  4733.  
  4734.  
  4735.  
  4736.  
  4737.  
  4738.  
  4739.  
  4740.  
  4741.  
  4742.  
  4743.  
  4744.  
  4745.  
  4746.  
  4747.  
  4748.  
  4749.  
  4750.  
  4751.  
  4752.  
  4753.  
  4754.  
  4755.  
  4756.  
  4757.  
  4758.  
  4759.  
  4760.  
  4761.  
  4762.  
  4763.  
  4764.  
  4765.  
  4766.  
  4767.  
  4768.  
  4769.  
  4770.  
  4771.  
  4772.  
  4773.  
  4774.  
  4775.  
  4776.  
  4777.  
  4778.  
  4779.  
  4780.  
  4781. The Berkeley Utilities V1.0 --------------------------------------- xstr [3]
  4782.  
  4783.                                                          Regular expressions
  4784.  
  4785.     Regular expressions are mostly used to look  for character strings  in
  4786. text files.   If you just want to find instances  of the word  ``search'',
  4787. the corresponding regular expression is simply given as  ``search''.   But
  4788. the use of special characters allows  the simultaneous  search of  several
  4789. different strings or of classes of strings described  by a single  regular
  4790. expression.
  4791.     In  the  current  implementation,  matches  are recognized  only within  a
  4792. line;  there is no way to specify the character  ``newline'' in a  regular
  4793. expression.
  4794.  
  4795.     Special characters are used in regular expressions to specify  regular
  4796. expression operators.   Actually, the list of characters having a  special
  4797. meaning  depends  on  the  utility  where  the  regular  expression  is  used
  4798. (ed,grep,awk,  ...)  though  the  list  of available  operators  is the  same.
  4799. This  is  done  as  follows:   in  each context  there  is a  list of  `magic'
  4800. characters  which  have  special  meaning,  and  other  characters  specifying
  4801. operators must be quoted by preceding them by a \ to be understood; and to
  4802. specify the match of a `magic' character you must quote it with a \.
  4803.     For instance, the operator + (meaning ``one or more repetitions'')  is
  4804. invoked by + or \+ depending  on whether  it is  `magic' or  not.   It  is
  4805. `magic' in awk but not in grep.   So in awk you write  a+ to match one  or
  4806. more a's, but you write a\+ to match the string ``a+''; while in  grep you
  4807. must write a\+ to match one or more a's and a+ to match the string a+.
  4808.     `\' is always `magic', so you must quote the \ itself, and specify  it
  4809. by `\\'.  The following other characters can be `magic':
  4810.  
  4811.     []().*+?\ except within brackets [].
  4812.     ^         at the beginning of an expression or as the first  character
  4813.               encountered within brackets [].
  4814.     $         at the end of an expression.
  4815.  
  4816. Meaning of the special characters:
  4817.  
  4818.     [] A set of characters within brackets [] is a regular expression which
  4819.        matches any of the characters within brackets.   It is possible  to
  4820.        specify  a  range  of  characters  (in  the ASCII  collating  sequence)
  4821.        using the - character:   for instance, [a-z] matches any  character
  4822.        whose ASCII code is between that of a  and that of  z, that is  any
  4823.        lower-case letter.   However the character - given as the first one
  4824.        after [ or the last one before ] is taken for itself.  If the first
  4825.        character after [ is ^ the match will be with characters which  are
  4826.        not in the specified set (i.e.   which are in the complement set in
  4827.        the ASCII table).   To specify a [  or a  ] it must  appear as  the
  4828.        first character after [.   For instance []a-z] matches  `]' or  any
  4829.        lower-case letter; [^]a-z] is also allowed and matches any character
  4830.        but ] and lower-case letters.
  4831.     .  The dot is a regular expression matching any one character.
  4832.     ^  We have seen its meaning within brackets.   It  has also a  special
  4833.        meaning  as  the  first  character  of a  complete regular  expression:
  4834.        it indicates that the expression will match a  string only if  that
  4835.        string starts at the beginning of a line.
  4836.  
  4837.  
  4838. The Berkeley Utilities V1.0 ----------------------------------- Appendix [1]
  4839.  
  4840.     $  Similarly, the dollar has a special meaning  as the last  character
  4841.        of a complete regular expression, and indicates that the expression
  4842.        will match a string only if that string ends with the last character
  4843.        of a line.
  4844.  
  4845.     It is of course possible to use both  ^ and $  to build an  expression
  4846. which matches only complete lines.
  4847.  
  4848.     More complex regular expressions can be built  from the previous  ones
  4849. using the following operators (special characters):
  4850.     The concatenation of several regular expressions is an expression which
  4851. matches the concatenation of the strings matched by each expression.
  4852.     *              A  star  immediately  following  an  expression  indicates
  4853.                    repetition:  the expression will match any number (0 or
  4854.                    more)  of  consecutive  occurences  of  the string  matched
  4855.                    by the expression which the `*'  follows.   When  there
  4856.                    are several possible such matches,  the longest one  is
  4857.                    chosen.
  4858.     +              Is similar, but this time the match will occur for 1 or
  4859.                    more occurences of the string matched by the expression
  4860.                    which the `+' follows.   As in the  previous case,  the
  4861.                    longest possible match is chosen.
  4862.     ?              Is  again  similar,  but  the  match  occurs  for  0  or  1
  4863.                    occurence (the longest possible match is chosen).
  4864.     \{m\}          Also indicates repetition; m must be a positive integer
  4865.                    less  than  256.     The  match  occurs  for  exactly  m
  4866.                    occurrences.
  4867.     \{m,\}         Is similar; the match occurs for a number of occurences
  4868.                    equal to or greater than m (the longest match is  taken
  4869.                    when there are several possible solutions).
  4870.     \{m,n\}        n must also be a positive integer less than  256.   The
  4871.                    match occurs for a number of occurences between m and n.
  4872.                    The longest match is again taken in case of doubt.
  4873.     \(expression\) The  parentheses  do  not  modify  the  meaning  of  the
  4874.                    enclosed expressions;  they are just used to capture  a
  4875.                    subexpression which gives meaning to the following form:
  4876.  
  4877.     \n             Where  n  is  a  single  digit  matches  exactly  the  same
  4878.                    string as the one which has just been matched by the nth
  4879.                    sub-regular expression enclosed within ( and  ) in  the
  4880.                    same expression (the occurence of \n must of course  be
  4881.                    after the nth occurence of ( in the expression).
  4882.     \<             Word beginning.   A match will occur only with a string
  4883.                    which  at  the  corresponding  place  does  not  contain  a
  4884.                    digit or a letter or is not  immediately preceded by  a
  4885.                    digit or a letter (the character ``_'' is considered as
  4886.                    a letter).
  4887.  
  4888.     \>             Word end.   A match will occur only with a string which
  4889.                    at the corresponding place does not contain a digit  or
  4890.                    is not immediately followed by a digit or a letter (the
  4891.                    character ``_'' is considered as a letter).
  4892.  
  4893.  
  4894.  
  4895. [2] Appendix ----------------------------------- The Berkeley Utilities V1.0
  4896.  
  4897. Examples:
  4898.  
  4899.     The regular expression:
  4900.  
  4901.     (<[a-zA-Z]{5,7}>).*\1
  4902.  
  4903. matches  only  2  occurrences  of  the  same  5  to  7  letter  word,  on  the
  4904. same  line  and  separated  by  any  number  of  characters  (this  is  `awk'
  4905. or  `egrep'  syntax;  the  same  expression  must  be  written  in  grep  as
  4906. \(\<[a-zA-Z]\{5,7\}\>\).*\1).
  4907.  
  4908.  
  4909.  
  4910.  
  4911.  
  4912.  
  4913.  
  4914.  
  4915.  
  4916.  
  4917.  
  4918.  
  4919.  
  4920.  
  4921.  
  4922.  
  4923.  
  4924.  
  4925.  
  4926.  
  4927.  
  4928.  
  4929.  
  4930.  
  4931.  
  4932.  
  4933.  
  4934.  
  4935.  
  4936.  
  4937.  
  4938.  
  4939.  
  4940.  
  4941.  
  4942.  
  4943.  
  4944.  
  4945.  
  4946.  
  4947.  
  4948.  
  4949.  
  4950.  
  4951.  
  4952. The Berkeley Utilities V1.0 ----------------------------------- Appendix [3]
  4953.