home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / unix / begin.doc < prev    next >
Encoding:
Text File  |  2003-06-11  |  84.4 KB  |  3,216 lines

  1. B
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.              UUUUNNNNIIIIXXXX FFFFoooorrrr BBBBeeeeggggiiiinnnnnnnneeeerrrrssss----SSSSeeeeccccoooonnnndddd EEEEddddiiiittttiiiioooonnnn
  12.  
  13.  
  14.  
  15.                      Brian W. Kernighan
  16.  
  17.  
  18.                      Bell Laboratories
  19.  
  20.                Murray Hill, New Jersey 07974
  21.  
  22.  
  23.  
  24.                           _A_B_S_T_R_A_C_T
  25.  
  26.  
  27.        This paper  is  meant  to  help  new  users  get
  28.      started  on  the  UNIX*  operating   system.    It
  29.      includes:
  30.  
  31.       o+basics needed for day-to-day use of the system -
  32.        typing  commands,  correcting  typing  mistakes,
  33.        logging in and out, mail, inter-terminal commun-
  34.        ication,   the   file  system,  printing  files,
  35.        redirecting I/O, pipes, and the shell.
  36.  
  37.       o+document preparation - a brief discussion of the
  38.        major  formatting  programs  and macro packages,
  39.        hints  on  preparing  documents,   and   capsule
  40.        descriptions of some supporting software.
  41.  
  42.       o+UNIX programming - using the editor, programming
  43.        the shell, programming in C, other languages and
  44.        tools.
  45.  
  46.       o+An annotated UNIX bibliography.
  47.  
  48.  
  49.  
  50. _I_N_T_R_O_D_U_C_T_I_O_N
  51.  
  52.  
  53.   From the user's point of view, the UNIX  operating  system
  54.  
  55. is  easy  to  learn  and  use, and presents few of the usual
  56.  
  57. impediments to getting the job done.  It is  hard,  however,
  58.  
  59. __________________________
  60. * UNIX is a Trademark of Bell Laboratories.
  61.  
  62.  
  63.  
  64.                      November 16, 1985
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71. 2                                         _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  72.  
  73.  
  74. for the beginner to know where to start, and how to make the
  75.  
  76. best  use  of the facilities available.  The purpose of this
  77.  
  78. introduction is to help new users get used to the main ideas
  79.  
  80. of  the  UNIX  system  and  start making effective use of it
  81.  
  82. quickly.
  83.  
  84.  
  85.   You should have a couple of other documents with  you  for
  86.  
  87. easy  reference as you read this one.  The most important is
  88.  
  89. _T_h_e _U_N_I_X _P_r_o_g_r_a_m_m_e_r'_s _M_a_n_u_a_l; it's often easier to tell  you
  90.  
  91. to  read  about  something  in the manual than to repeat its
  92.  
  93. contents here.  The other  useful  document  is  _A  _T_u_t_o_r_i_a_l
  94.  
  95. _I_n_t_r_o_d_u_c_t_i_o_n  _t_o  _t_h_e  _U_N_I_X _T_e_x_t _E_d_i_t_o_r, which will tell you
  96.  
  97. how to use the editor to get text -  programs,  data,  docu-
  98.  
  99. ments - into the computer.
  100.  
  101.  
  102.   A word of warning: the UNIX system has become quite  popu-
  103.  
  104. lar, and there are several major variants in widespread use.
  105.  
  106. Of course details also change with time.   So  although  the
  107.  
  108. basic  structure  of UNIX and how to use it is common to all
  109.  
  110. versions, there will certainly be a  few  things  which  are
  111.  
  112. different  on  your  system from what is described here.  We
  113.  
  114. have tried to minimize the problem, but be aware of it.   In
  115.  
  116. cases of doubt, this paper describes Version 7 UNIX.
  117.  
  118.  
  119.   This paper has five sections:
  120.  
  121.  
  122.   1.Getting Started: How to log in, how to type, what to  do
  123.  
  124.   about mistakes in typing, how to log out.  Some of this is
  125.  
  126.   dependent on which system you log into (phone numbers, for
  127.  
  128.  
  129.  
  130.                      November 16, 1985
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                         3
  138.  
  139.  
  140.   example)  and  what terminal you use, so this section must
  141.  
  142.   necessarily be supplemented by local information.
  143.  
  144.  
  145.   2.Day-to-day Use: Things you need every  day  to  use  the
  146.  
  147.   system  effectively:  generally  useful commands; the file
  148.  
  149.   system.
  150.  
  151.  
  152.   3.Document Preparation: Preparing manuscripts  is  one  of
  153.  
  154.   the  most common uses for UNIX systems.  This section con-
  155.  
  156.   tains advice, but not extensive instructions on any of the
  157.  
  158.   formatting tools.
  159.  
  160.  
  161.   4.Writing  Programs:  UNIX  is  an  excellent  system  for
  162.  
  163.   developing programs.  This section talks about some of the
  164.  
  165.   tools, but again is not a tutorial in any of the  program-
  166.  
  167.   ming languages provided by the system.
  168.  
  169.  
  170.   5.A UNIX Reading List.  An annotated bibliography of docu-
  171.  
  172.   ments that new users should be aware of.
  173.  
  174.  
  175. _I.  _G_E_T_T_I_N_G _S_T_A_R_T_E_D
  176.  
  177.  
  178. _L_o_g_g_i_n_g _I_n
  179.  
  180.  
  181.   You must have a UNIX login name, which you  can  get  from
  182.  
  183. whoever  administers your system.  You also need to know the
  184.  
  185. phone number, unless your system uses permanently  connected
  186.  
  187. terminals.   The  UNIX  system  is capable of dealing with a
  188.  
  189. wide variety of terminals: Terminet 300's; Execuport, TI and
  190.  
  191. similar  portables;  video  (CRT) terminals like the HP2640,
  192.  
  193. etc.; high-priced  graphics  terminals  like  the  Tektronix
  194.  
  195.  
  196.                      November 16, 1985
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203. 4                                         _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  204.  
  205.  
  206. 4014;  plotting  terminals like those from GSI and DASI; and
  207.  
  208. even the venerable Teletype in its various forms.  But note:
  209.  
  210. UNIX  is  strongly oriented towards devices with _l_o_w_e_r _c_a_s_e.
  211.  
  212. If your terminal produces only upper case  (e.g.,  model  33
  213.  
  214. Teletype,  some  video and portable terminals), life will be
  215.  
  216. so difficult that you should look for another terminal.
  217.  
  218.  
  219.   Be sure to set the switches appropriately on your  device.
  220.  
  221. Switches  that  might need to be adjusted include the speed,
  222.  
  223. upper/lower case mode, full duplex,  even  parity,  and  any
  224.  
  225. others  that  local  wisdom advises.  Establish a connection
  226.  
  227. using whatever magic is needed for your terminal;  this  may
  228.  
  229. involve  dialing  a  telephone  call  or  merely  flipping a
  230.  
  231. switch.  In either case, UNIX should type ``llllooooggggiiiinnnn::::'' at you.
  232.  
  233. If  it  types  garbage, you may be at the wrong speed; check
  234.  
  235. the switches.  If that fails, push the ``break'' or ``inter-
  236.  
  237. rupt''  key a few times, slowly.  If that fails to produce a
  238.  
  239. login message, consult a guru.
  240.  
  241.  
  242.   When you get a llllooooggggiiiinnnn:::: message, type  your  login  name  _i_n
  243.  
  244. _l_o_w_e_r  _c_a_s_e.   Follow it by a RETURN; the system will not do
  245.  
  246. anything  until  you  type  a  RETURN.   If  a  password  is
  247.  
  248. required, you will be asked for it, and (if possible) print-
  249.  
  250. ing will be turned off while  you  type  it.   Don't  forget
  251.  
  252. RETURN.
  253.  
  254.  
  255.   The culmination of your login efforts is a ``prompt  char-
  256.  
  257. acter,''  a  single character that indicates that the system
  258.  
  259. is ready to accept commands from you.  The prompt  character
  260.  
  261.  
  262.                      November 16, 1985
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                         5
  270.  
  271.  
  272. is  usually  a  dollar sign $$$$ or a percent sign %%%%.  (You may
  273.  
  274. also get a message of the day just before the prompt charac-
  275.  
  276. ter, or a notification that you have mail.)
  277.  
  278.  
  279. _T_y_p_i_n_g _C_o_m_m_a_n_d_s
  280.  
  281.  
  282.   Once you've seen the prompt character, you can  type  com-
  283.  
  284. mands, which are requests that the system do something.  Try
  285.  
  286. typing
  287.  
  288.  
  289.   ddddaaaatttteeee
  290.  
  291. followed by RETURN.  You should get back something like
  292.  
  293.  
  294.   MMMMoooonnnn JJJJaaaannnn 11116666 11114444::::11117777::::11110000 EEEESSSSTTTT 1111999977778888
  295.  
  296. Don't forget the RETURN after the command, or  nothing  will
  297.  
  298. happen.   If  you think you're being ignored, type a RETURN;
  299.  
  300. something should happen.  RETURN won't be  mentioned  again,
  301.  
  302. but  don't forget it - it has to be there at the end of each
  303.  
  304. line.
  305.  
  306.  
  307.   Another command you might try  is  wwwwhhhhoooo,  which  tells  you
  308.  
  309. everyone who is currently logged in:
  310.  
  311.  
  312.   wwwwhhhhoooo
  313.  
  314. gives something like
  315.  
  316.  
  317.   mmmmbbbb   ttttttttyyyy00001111JJJJaaaannnn 11116666    00009999::::11111111
  318.   sssskkkkiiii  ttttttttyyyy00005555JJJJaaaannnn 11116666    00009999::::33333333
  319.   ggggaaaammmm  ttttttttyyyy11111111JJJJaaaannnn 11116666    11113333::::00007777
  320.  
  321. The time is when  the  user  logged  in;  ``ttyxx''  is  the
  322.  
  323. system's idea of what terminal the user is on.
  324.  
  325.  
  326.  
  327.  
  328.                      November 16, 1985
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335. 6                                         _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  336.  
  337.  
  338.   If you make a mistake typing the command name,  and  refer
  339.  
  340. to  a  non-existent command, you will be told.  For example,
  341.  
  342. if you type
  343.  
  344.  
  345.   wwwwhhhhoooommmm
  346.  
  347. you will be told
  348.  
  349.  
  350.   wwwwhhhhoooommmm:::: nnnnooootttt ffffoooouuuunnnndddd
  351.  
  352. Of course, if you inadvertently type the name of some  other
  353.  
  354. command, it will run, with more or less mysterious results.
  355.  
  356.  
  357. _S_t_r_a_n_g_e _T_e_r_m_i_n_a_l _B_e_h_a_v_i_o_r
  358.  
  359.  
  360.   Sometimes you can get into a  state  where  your  terminal
  361.  
  362. acts  strangely.   For  example,  each  letter  may be typed
  363.  
  364. twice, or the RETURN may not cause a line feed or  a  return
  365.  
  366. to  the  left margin.  You can often fix this by logging out
  367.  
  368. and logging back in.  Or you can read the description of the
  369.  
  370. command ssssttttttttyyyy in section I of the manual.  To get intelligent
  371.  
  372. treatment of tab characters (which are much used in UNIX) if
  373.  
  374. your terminal doesn't have tabs, type the command
  375.  
  376.  
  377.   ssssttttttttyyyy ----ttttaaaabbbbssss
  378.  
  379. and the system will convert each tab into the  right  number
  380.  
  381. of  blanks  for  you.   If your terminal does have computer-
  382.  
  383. settable tabs, the command ttttaaaabbbbssss will set the stops correctly
  384.  
  385. for you.
  386.  
  387.  
  388. _M_i_s_t_a_k_e_s _i_n _T_y_p_i_n_g
  389.  
  390.  
  391.   If you make a typing mistake, and see it before RETURN has
  392.  
  393.  
  394.                      November 16, 1985
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                         7
  402.  
  403.  
  404. been  typed,  there  are  two  ways  to recover.  The sharp-
  405.  
  406. character #### erases the last character typed; in fact succes-
  407.  
  408. sive uses of #### erase characters back to the beginning of the
  409.  
  410. line (but not beyond).   So  if  you  type  badly,  you  can
  411.  
  412. correct as you go:
  413.  
  414.  
  415.   dddddddd####aaaatttttttteeee########eeee
  416.  
  417. is the same as ddddaaaatttteeee.
  418.  
  419.  
  420.   The at-sign @@@@ erases all of the characters typed so far on
  421.  
  422. the  current  input  line,  so  if the line is irretrievably
  423.  
  424. fouled up, type an @@@@ and start the line over.
  425.  
  426.  
  427.   What if you must enter a sharp or at-sign as part  of  the
  428.  
  429. text?   If  you  precede  either #### or @@@@ by a backslash \\\\, it
  430.  
  431. loses its erase meaning.  So to enter a sharp or at-sign  in
  432.  
  433. something,  type  \\\\####  or  \\\\@@@@.  The system will always echo a
  434.  
  435. newline at you after your at-sign, even  if  preceded  by  a
  436.  
  437. backslash.  Don't worry - the at-sign has been recorded.
  438.  
  439.  
  440.   To erase a backslash, you have to type two sharps  or  two
  441.  
  442. at-signs,  as  in \\\\########.  The backslash is used extensively in
  443.  
  444. UNIX to indicate that the following character is in some way
  445.  
  446. special.
  447.  
  448.  
  449. _R_e_a_d-_a_h_e_a_d
  450.  
  451.  
  452.   UNIX has full read-ahead, which means that you can type as
  453.  
  454. fast  as you want, whenever you want, even when some command
  455.  
  456. is typing at you.  If you type  during  output,  your  input
  457.  
  458.  
  459.  
  460.                      November 16, 1985
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467. 8                                         _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  468.  
  469.  
  470. characters  will  appear  intermixed with the output charac-
  471.  
  472. ters, but they will be stored away and  interpreted  in  the
  473.  
  474. correct  order.   So you can type several commands one after
  475.  
  476. another without waiting for the  first  to  finish  or  even
  477.  
  478. begin.
  479.  
  480.  
  481. _S_t_o_p_p_i_n_g _a _P_r_o_g_r_a_m
  482.  
  483.  
  484.   You can stop most programs by typing the character ``DEL''
  485.  
  486. (perhaps  called ``delete'' or ``rubout'' on your terminal).
  487.  
  488. The ``interrupt'' or ``break'' key found on  most  terminals
  489.  
  490. can  also be used.  In a few programs, like the text editor,
  491.  
  492. DEL stops whatever the program is doing but  leaves  you  in
  493.  
  494. that program.  Hanging up the phone will stop most programs.
  495.  
  496.  
  497. _L_o_g_g_i_n_g _O_u_t
  498.  
  499.  
  500.   The easiest way to log out is to hang up the  phone.   You
  501.  
  502. can also type
  503.  
  504.  
  505.   llllooooggggiiiinnnn
  506.  
  507. and let someone else use the terminal you were  on.   It  is
  508.  
  509. usually  not sufficient just to turn off the terminal.  Most
  510.  
  511. UNIX systems do not use a time-out mechanism, so  you'll  be
  512.  
  513. there forever unless you hang up.
  514.  
  515.  
  516. _M_a_i_l
  517.  
  518.  
  519.   When you log in, you may sometimes get the message
  520.  
  521.  
  522.   YYYYoooouuuu hhhhaaaavvvveeee mmmmaaaaiiiillll....
  523.  
  524.  
  525.  
  526.                      November 16, 1985
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                         9
  534.  
  535.  
  536. UNIX provides a postal system so you  can  communicate  with
  537.  
  538. other users of the system.  To read your mail, type the com-
  539.  
  540. mand
  541.  
  542.  
  543.   mmmmaaaaiiiillll
  544.  
  545. Your mail will be printed,  one  message  at  a  time,  most
  546.  
  547. recent  message  first.   After each message, mmmmaaaaiiiillll waits for
  548.  
  549. you to say what to do with it.  The two basic responses  are
  550.  
  551. dddd, which deletes the message, and RETURN, which does not (so
  552.  
  553. it will still be there the next time you read your mailbox).
  554.  
  555. Other  responses are described in the manual.  (Earlier ver-
  556.  
  557. sions of mmmmaaaaiiiillll do not process one message at a time, but  are
  558.  
  559. otherwise similar.)
  560.  
  561.  
  562.   How do you send mail to someone else?  Suppose it is to go
  563.  
  564. to  ``joe'' (assuming ``joe'' is someone's login name).  The
  565.  
  566. easiest way is this:
  567.  
  568.  
  569.   mmmmaaaaiiiillll jjjjooooeeee
  570.   _n_o_w _t_y_p_e _i_n _t_h_e _t_e_x_t _o_f _t_h_e _l_e_t_t_e_r
  571.   _o_n _a_s _m_a_n_y _l_i_n_e_s _a_s _y_o_u _l_i_k_e ...
  572.   _A_f_t_e_r _t_h_e _l_a_s_t _l_i_n_e _o_f _t_h_e _l_e_t_t_e_r
  573.   _t_y_p_e _t_h_e _c_h_a_r_a_c_t_e_r ``_c_o_n_t_r_o_l-_d'',
  574.   _t_h_a_t _i_s, _h_o_l_d _d_o_w_n ``_c_o_n_t_r_o_l'' _a_n_d _t_y_p_e
  575.   _a _l_e_t_t_e_r ``_d''.
  576.  
  577. And that's it.  The  ``control-d''  sequence,  often  called
  578.  
  579. ``EOF''  for  end-of-file,  is used throughout the system to
  580.  
  581. mark the end of input from a terminal, so you might as  well
  582.  
  583. get used to it.
  584.  
  585.  
  586.   For practice, send  mail  to  yourself.   (This  isn't  as
  587.  
  588. strange  as it might sound - mail to oneself is a handy rem-
  589.  
  590.  
  591.  
  592.                      November 16, 1985
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599. 10                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  600.  
  601.  
  602. inder mechanism.)
  603.  
  604.  
  605.   There are other ways to send mail - you can send a  previ-
  606.  
  607. ously  prepared letter, and you can mail to a number of peo-
  608.  
  609. ple all at once.  For more details see mmmmaaaaiiiillll(1).  (The  nota-
  610.  
  611. tion mmmmaaaaiiiillll(1) means the command mmmmaaaaiiiillll in section 1 of the _U_N_I_X
  612.  
  613. _P_r_o_g_r_a_m_m_e_r'_s _M_a_n_u_a_l.)
  614.  
  615.  
  616. _W_r_i_t_i_n_g _t_o _o_t_h_e_r _u_s_e_r_s
  617.  
  618.  
  619.   At some point, out of the blue will come a message like
  620.  
  621.  
  622.   MMMMeeeessssssssaaaaggggeeee ffffrrrroooommmm jjjjooooeeee ttttttttyyyy00007777............
  623.  
  624. accompanied by a startling beep.  It means that Joe wants to
  625.  
  626. talk  to  you, but unless you take explicit action you won't
  627.  
  628. be able to talk back.  To respond, type the command
  629.  
  630.  
  631.   wwwwrrrriiiitttteeee jjjjooooeeee
  632.  
  633. This establishes a two-way communication path.  Now whatever
  634.  
  635. Joe  types  on  his  terminal  will appear on yours and vice
  636.  
  637. versa.  The path is slow, rather like talking to  the  moon.
  638.  
  639. (If you are in the middle of something, you have to get to a
  640.  
  641. state where you can type a command.  Normally, whatever pro-
  642.  
  643. gram  you are running has to terminate or be terminated.  If
  644.  
  645. you're editing, you can escape temporarily from the editor -
  646.  
  647. read the editor tutorial.)
  648.  
  649.  
  650.   A protocol is needed to keep what you  type  from  getting
  651.  
  652. garbled up with what Joe types. Typically it's like this:
  653.  
  654.  
  655.  
  656.  
  657.  
  658.                      November 16, 1985
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        11
  666.  
  667.  
  668.  
  669.   Joe types wwwwrrrriiiitttteeee ssssmmmmiiiitttthhhh and waits.
  670.   Smith types wwwwrrrriiiitttteeee jjjjooooeeee and waits.
  671.   Joe now types his message (as many  lines  as  he  likes).
  672.   When  he's ready for a reply, he signals it by typing ((((oooo)))),
  673.   which stands for ``over''.
  674.   Now Smith types a reply, also terminated by ((((oooo)))).
  675.   This cycle repeats  until  someone  gets  tired;  he  then
  676.   signals  his  intent  to  quit  with  ((((oooooooo)))), for ``over and
  677.   out''.
  678.   To terminate the  conversation,  each  side  must  type  a
  679.   ``control-d''  character alone on a line. (``Delete'' also
  680.   works.) When the other person types his ``control-d'', you
  681.   will get the message EEEEOOOOFFFF on your terminal.
  682.  
  683.  
  684.  
  685.   If you write to  someone  who  isn't  logged  in,  or  who
  686.  
  687. doesn't want to be disturbed, you'll be told.  If the target
  688.  
  689. is logged in but doesn't answer  after  a  decent  interval,
  690.  
  691. simply type ``control-d''.
  692.  
  693.  
  694. _O_n-_l_i_n_e _M_a_n_u_a_l
  695.  
  696.  
  697.   The _U_N_I_X _P_r_o_g_r_a_m_m_e_r'_s _M_a_n_u_a_l is  typically  kept  on-line.
  698.  
  699. If  you  get stuck on something, and can't find an expert to
  700.  
  701. assist you, you can print on your terminal some manual  sec-
  702.  
  703. tion  that  might help.  This is also useful for getting the
  704.  
  705. most up-to-date information on a command.  To print a manual
  706.  
  707. section,  type ``man command-name''.  Thus to read up on the
  708.  
  709. wwwwhhhhoooo command, type
  710.  
  711.  
  712.   mmmmaaaannnn wwwwhhhhoooo
  713.  
  714. and, of course,
  715.  
  716.  
  717.   mmmmaaaannnn mmmmaaaannnn
  718.  
  719. tells all about the mmmmaaaannnn command.
  720.  
  721.  
  722.  
  723.  
  724.                      November 16, 1985
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731. 12                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  732.  
  733.  
  734. _C_o_m_p_u_t_e_r _A_i_d_e_d _I_n_s_t_r_u_c_t_i_o_n
  735.  
  736.  
  737.   Your UNIX system  may  have  available  a  program  called
  738.  
  739. lllleeeeaaaarrrrnnnn, which provides computer aided instruction on the file
  740.  
  741. system and basic commands, the editor, document preparation,
  742.  
  743. and even C programming.  Try typing the command
  744.  
  745.  
  746.   lllleeeeaaaarrrrnnnn
  747.  
  748. If lllleeeeaaaarrrrnnnn exists on your system, it will tell you what to  do
  749.  
  750. from there.
  751.  
  752.  
  753. _I_I.  _D_A_Y-_T_O-_D_A_Y _U_S_E
  754.  
  755.  
  756. _C_r_e_a_t_i_n_g _F_i_l_e_s - _T_h_e _E_d_i_t_o_r
  757.  
  758.  
  759.   If you have to type a paper or a letter or a program,  how
  760.  
  761. do  you  get the information stored in the machine?  Most of
  762.  
  763. these tasks are done  with  the  UNIX  ``text  editor''  eeeedddd.
  764.  
  765. Since  eeeedddd is thoroughly documented in eeeedddd(1) and explained in
  766.  
  767. _A _T_u_t_o_r_i_a_l _I_n_t_r_o_d_u_c_t_i_o_n _t_o _t_h_e _U_N_I_X _T_e_x_t  _E_d_i_t_o_r,  we  won't
  768.  
  769. spend  any  time here describing how to use it.  All we want
  770.  
  771. it for right now is to make some _f_i_l_e_s.  (A file is  just  a
  772.  
  773. collection  of information stored in the machine, a simplis-
  774.  
  775. tic but adequate definition.)
  776.  
  777.  
  778.   To create a file called jjjjuuuunnnnkkkk with some text in it, do  the
  779.  
  780. following:
  781.  
  782.  
  783.   eeeedddd jjjjuuuunnnnkkkk(invokes the text editor)
  784.   aaaa     (command to ``ed'', to add text)
  785.   _n_o_w _t_y_p_e _i_n
  786.   _w_h_a_t_e_v_e_r _t_e_x_t _y_o_u _w_a_n_t ...
  787.   ....     (signals the end of adding text)
  788.  
  789.  
  790.                      November 16, 1985
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        13
  798.  
  799.  
  800. The ``....'' that signals the end of adding text must be at the
  801.  
  802. beginning  of  a line by itself.  Don't forget it, for until
  803.  
  804. it is typed, no other  eeeedddd  commands  will  be  recognized  -
  805.  
  806. everything you type will be treated as text to be added.
  807.  
  808.  
  809.   At this point you can do various editing operations on the
  810.  
  811. text  you  typed  in,  such as correcting spelling mistakes,
  812.  
  813. rearranging paragraphs and  the  like.   Finally,  you  must
  814.  
  815. write  the  information  you have typed into a file with the
  816.  
  817. editor command wwww:
  818.  
  819.  
  820.   wwww
  821.  
  822. eeeedddd will respond with the number of characters it wrote  into
  823.  
  824. the file jjjjuuuunnnnkkkk.
  825.  
  826.  
  827.   Until the wwww command, nothing is stored permanently, so  if
  828.  
  829. you hang up and go home the information is lost.|- But  after
  830.  
  831. wwww the information is there permanently; you can re-access it
  832.  
  833. any time by typing
  834.  
  835.  
  836.   eeeedddd jjjjuuuunnnnkkkk
  837.  
  838. Type a qqqq command to quit the editor.  (If you  try  to  quit
  839.  
  840. without  writing, eeeedddd will print a ???? to remind you.  A second
  841.  
  842. qqqq gets you out regardless.)
  843.  
  844.  
  845.   Now create a second file called tttteeeemmmmpppp in the  same  manner.
  846.  
  847. You should now have two files, jjjjuuuunnnnkkkk and tttteeeemmmmpppp.
  848. __________________________
  849. |- This is not strictly true -  if  you  hang  up  while
  850. editing,  the  data  you  were working on is saved in a
  851. file called eeeedddd....hhhhuuuupppp, which you can continue with at your
  852. next session.
  853.  
  854.  
  855.  
  856.                      November 16, 1985
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863. 14                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  864.  
  865.  
  866. _W_h_a_t _f_i_l_e_s _a_r_e _o_u_t _t_h_e_r_e?
  867.  
  868.  
  869.   The llllssss (for ``list'') command lists the  names  (not  con-
  870.  
  871. tents)  of  any  of the files that UNIX knows about.  If you
  872.  
  873. type
  874.  
  875.  
  876.   llllssss
  877.  
  878. the response will be
  879.  
  880.  
  881.   jjjjuuuunnnnkkkk
  882.   tttteeeemmmmpppp
  883.  
  884. which are indeed the two files just created.  The names  are
  885.  
  886. sorted  into  alphabetical  order  automatically,  but other
  887.  
  888. variations are possible.  For example, the command
  889.  
  890.  
  891.   llllssss ----tttt
  892.  
  893. causes the files to be listed in the  order  in  which  they
  894.  
  895. were last changed, most recent first.  The ----llll option gives a
  896.  
  897. ``long'' listing:
  898.  
  899.  
  900.   llllssss ----llll
  901.  
  902. will produce something like
  903.  
  904.  
  905.   ----rrrrwwww----rrrrwwww----rrrrwwww---- 1111 bbbbwwwwkkkk 44441111 JJJJuuuullll 22222222 2222::::55556666 jjjjuuuunnnnkkkk
  906.   ----rrrrwwww----rrrrwwww----rrrrwwww---- 1111 bbbbwwwwkkkk 77778888 JJJJuuuullll 22222222 2222::::55557777 tttteeeemmmmpppp
  907.  
  908. The date and time are of the last change to the  file.   The
  909.  
  910. 41  and  78 are the number of characters (which should agree
  911.  
  912. with the numbers you got from eeeedddd).  bbbbwwwwkkkk is the owner of  the
  913.  
  914. file,  that  is,  the person who created it.  The ----rrrrwwww----rrrrwwww----rrrrwwww----
  915.  
  916. tells who has permission to read and write the file, in this
  917.  
  918. case everyone.
  919.  
  920.  
  921.  
  922.                      November 16, 1985
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        15
  930.  
  931.  
  932.   Options can be combined: llllssss ----lllltttt gives the  same  thing  as
  933.  
  934. llllssss ----llll,  but  sorted  into time order.  You can also name the
  935.  
  936. files you're interested in, and llllssss will list the information
  937.  
  938. about them only.  More details can be found in llllssss(1).
  939.  
  940.  
  941.   The use of optional arguments  that  begin  with  a  minus
  942.  
  943. sign,  like ----tttt and ----lllltttt, is a common convention for UNIX pro-
  944.  
  945. grams.  In general, if a program accepts such optional argu-
  946.  
  947. ments,  they  precede  any  filename  arguments.  It is also
  948.  
  949. vital that you separate the various arguments  with  spaces:
  950.  
  951. llllssss----llll is not the same as llllssss  ----llll.
  952.  
  953.  
  954. _P_r_i_n_t_i_n_g _F_i_l_e_s
  955.  
  956.  
  957.   Now that you've got a file of text, how do you print it so
  958.  
  959. people can look at it?  There are a host of programs that do
  960.  
  961. that, probably more than are needed.
  962.  
  963.  
  964.   One simple thing is to use the editor, since  printing  is
  965.  
  966. often done just before making changes anyway.  You can say
  967.  
  968.  
  969.   eeeedddd jjjjuuuunnnnkkkk
  970.   1111,,,,$$$$pppp
  971.  
  972. eeeedddd will reply with the count of the characters in  jjjjuuuunnnnkkkk  and
  973.  
  974. then  print  all the lines in the file.  After you learn how
  975.  
  976. to use the editor, you can be selective about the parts  you
  977.  
  978. print.
  979.  
  980.  
  981.   There are times when it's not feasible to use  the  editor
  982.  
  983. for  printing.   For  example, there is a limit on how big a
  984.  
  985. file eeeedddd can handle (several thousand lines).   Secondly,  it
  986.  
  987.  
  988.                      November 16, 1985
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995. 16                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  996.  
  997.  
  998. will  only  print one file at a time, and sometimes you want
  999.  
  1000. to print several, one after another.  So here are  a  couple
  1001.  
  1002. of alternatives.
  1003.  
  1004.  
  1005.   First is ccccaaaatttt, the simplest of all the  printing  programs.
  1006.  
  1007. ccccaaaatttt  simply  prints  on the terminal the contents of all the
  1008.  
  1009. files named in a list.  Thus
  1010.  
  1011.  
  1012.   ccccaaaatttt jjjjuuuunnnnkkkk
  1013.  
  1014. prints one file, and
  1015.  
  1016.  
  1017.   ccccaaaatttt jjjjuuuunnnnkkkk tttteeeemmmmpppp
  1018.  
  1019. prints two.  The files are simply  concatenated  (hence  the
  1020.  
  1021. name ``ccccaaaatttt'') onto the terminal.
  1022.  
  1023.  
  1024.   pppprrrr produces formatted printouts of files.  As with ccccaaaatttt, pppprrrr
  1025.  
  1026. prints  all  the  files  named in a list.  The difference is
  1027.  
  1028. that it produces headings with date, time, page  number  and
  1029.  
  1030. file  name  at the top of each page, and extra lines to skip
  1031.  
  1032. over the fold in the paper.  Thus,
  1033.  
  1034.  
  1035.   pppprrrr jjjjuuuunnnnkkkk tttteeeemmmmpppp
  1036.  
  1037. will print jjjjuuuunnnnkkkk neatly, then skip to the top of a  new  page
  1038.  
  1039. and print tttteeeemmmmpppp neatly.
  1040.  
  1041.  
  1042.   pppprrrr can also produce multi-column output:
  1043.  
  1044.  
  1045.   pppprrrr ----3333 jjjjuuuunnnnkkkk
  1046.  
  1047. prints jjjjuuuunnnnkkkk in 3-column format.  You can use any  reasonable
  1048.  
  1049. number  in  place  of ``3'' and pppprrrr will do its best.  pppprrrr has
  1050.  
  1051. other capabilities as well; see pppprrrr(1).
  1052.  
  1053.  
  1054.                      November 16, 1985
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        17
  1062.  
  1063.  
  1064.   It should be noted that pppprrrr is _n_o_t a formatting program  in
  1065.  
  1066. the  sense of shuffling lines around and justifying margins.
  1067.  
  1068. The true formatters are nnnnrrrrooooffffffff and ttttrrrrooooffffffff, which we  will  get
  1069.  
  1070. to in the section on document preparation.
  1071.  
  1072.  
  1073.   There are also programs that print files on  a  high-speed
  1074.  
  1075. printer.   Look  in your manual under oooopppprrrr and llllpppprrrr.  Which to
  1076.  
  1077. use depends on what equipment is attached to your machine.
  1078.  
  1079.  
  1080. _S_h_u_f_f_l_i_n_g _F_i_l_e_s _A_b_o_u_t
  1081.  
  1082.  
  1083.   Now that you have some files in the file system  and  some
  1084.  
  1085. experience in printing them, you can try bigger things.  For
  1086.  
  1087. example, you can move a  file  from  one  place  to  another
  1088.  
  1089. (which amounts to giving it a new name), like this:
  1090.  
  1091.  
  1092.   mmmmvvvv jjjjuuuunnnnkkkk pppprrrreeeecccciiiioooouuuussss
  1093.  
  1094. This means that what used  to  be  ``junk''  is  now  ``pre-
  1095.  
  1096. cious''.  If you do an llllssss command now, you will get
  1097.  
  1098.  
  1099.   pppprrrreeeecccciiiioooouuuussss
  1100.   tttteeeemmmmpppp
  1101.  
  1102. Beware that if you move a file to another one  that  already
  1103.  
  1104. exists, the already existing contents are lost forever.
  1105.  
  1106.  
  1107.   If you want to make a _c_o_p_y of a file (that is, to have two
  1108.  
  1109. versions of something), you can use the ccccpppp command:
  1110.  
  1111.  
  1112.   ccccpppp pppprrrreeeecccciiiioooouuuussss tttteeeemmmmpppp1111
  1113.  
  1114. makes a duplicate copy of pppprrrreeeecccciiiioooouuuussss in tttteeeemmmmpppp1111.
  1115.  
  1116.  
  1117.   Finally, when you get tired of creating and moving  files,
  1118.  
  1119.  
  1120.                      November 16, 1985
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127. 18                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  1128.  
  1129.  
  1130. there  is  a  command  to remove files from the file system,
  1131.  
  1132. called rrrrmmmm.
  1133.  
  1134.  
  1135.   rrrrmmmm tttteeeemmmmpppp tttteeeemmmmpppp1111
  1136.  
  1137. will remove both of the files named.
  1138.  
  1139.  
  1140.   You will get a warning message if one of the  named  files
  1141.  
  1142. wasn't  there,  but  otherwise  rrrrmmmm, like most UNIX commands,
  1143.  
  1144. does its work silently.  There is no prompting  or  chatter,
  1145.  
  1146. and error messages are occasionally curt.  This terseness is
  1147.  
  1148. sometimes disconcerting to newcomers, but experienced  users
  1149.  
  1150. find it desirable.
  1151.  
  1152.  
  1153. _W_h_a_t'_s _i_n _a _F_i_l_e_n_a_m_e
  1154.  
  1155.  
  1156.   So far we have used filenames without ever saying what's a
  1157.  
  1158. legal  name,  so  it's  time  for a couple of rules.  First,
  1159.  
  1160. filenames are limited to 14 characters, which is  enough  to
  1161.  
  1162. be  descriptive.   Second,  although  you can use almost any
  1163.  
  1164. character in a filename, common sense says you should  stick
  1165.  
  1166. to ones that are visible, and that you should probably avoid
  1167.  
  1168. characters that might be used with other meanings.  We  have
  1169.  
  1170. already  seen,  for  example,  that in the llllssss command, llllssss ----tttt
  1171.  
  1172. means to list in time order.  So if you  had  a  file  whose
  1173.  
  1174. name was ----tttt, you would have a tough time listing it by name.
  1175.  
  1176. Besides the minus sign, there  are  other  characters  which
  1177.  
  1178. have  special meaning.  To avoid pitfalls, you would do well
  1179.  
  1180. to use only letters, numbers and  the  period  until  you're
  1181.  
  1182. familiar with the situation.
  1183.  
  1184.  
  1185.  
  1186.                      November 16, 1985
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        19
  1194.  
  1195.  
  1196.   On to some more positive suggestions.  Suppose you're typ-
  1197.  
  1198. ing  a  large  document like a book.  Logically this divides
  1199.  
  1200. into many small pieces, like chapters and perhaps  sections.
  1201.  
  1202. Physically  it  must  be divided too, for eeeedddd will not handle
  1203.  
  1204. really big files.  Thus you should type the  document  as  a
  1205.  
  1206. number  of  files.   You might have a separate file for each
  1207.  
  1208. chapter, called
  1209.  
  1210.  
  1211.   cccchhhhaaaapppp1111
  1212.   cccchhhhaaaapppp2222
  1213.   etc...
  1214.  
  1215. Or, if each chapter were  broken  into  several  files,  you
  1216.  
  1217. might have
  1218.  
  1219.  
  1220.   cccchhhhaaaapppp1111....1111
  1221.   cccchhhhaaaapppp1111....2222
  1222.   cccchhhhaaaapppp1111....3333
  1223.   ............
  1224.   cccchhhhaaaapppp2222....1111
  1225.   cccchhhhaaaapppp2222....2222
  1226.   ............
  1227.  
  1228. You can now tell at a glance where a  particular  file  fits
  1229.  
  1230. into the whole.
  1231.  
  1232.  
  1233.   There are advantages to  a  systematic  naming  convention
  1234.  
  1235. which  are not obvious to the novice UNIX user.  What if you
  1236.  
  1237. wanted to print the whole book?  You could say
  1238.  
  1239.  
  1240.   pppprrrr cccchhhhaaaapppp1111....1111 cccchhhhaaaapppp1111....2222 cccchhhhaaaapppp1111....3333 ........................
  1241.  
  1242. but you would get tired pretty fast, and would probably even
  1243.  
  1244. make  mistakes.   Fortunately, there is a shortcut.  You can
  1245.  
  1246. say
  1247.  
  1248.  
  1249.   pppprrrr cccchhhhaaaapppp****
  1250.  
  1251.  
  1252.                      November 16, 1985
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259. 20                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  1260.  
  1261.  
  1262. The **** means ``anything at all,''  so  this  translates  into
  1263.  
  1264. ``print  all  files whose names begin with cccchhhhaaaapppp'', listed in
  1265.  
  1266. alphabetical order.
  1267.  
  1268.  
  1269.   This shorthand notation is not a property of the  pppprrrr  com-
  1270.  
  1271. mand,  by the way.  It is system-wide, a service of the pro-
  1272.  
  1273. gram that interprets commands (the ``shell,'' sssshhhh(1)).  Using
  1274.  
  1275. that fact, you can see how to list the names of the files in
  1276.  
  1277. the book:
  1278.  
  1279.  
  1280.   llllssss cccchhhhaaaapppp****
  1281.  
  1282. produces
  1283.  
  1284.  
  1285.   cccchhhhaaaapppp1111....1111
  1286.   cccchhhhaaaapppp1111....2222
  1287.   cccchhhhaaaapppp1111....3333
  1288.   ............
  1289.  
  1290. The **** is not limited to the last position in a filename - it
  1291.  
  1292. can be anywhere and can occur several times.  Thus
  1293.  
  1294.  
  1295.   rrrrmmmm ****jjjjuuuunnnnkkkk**** ****tttteeeemmmmpppp****
  1296.  
  1297. removes all files that contain jjjjuuuunnnnkkkk or tttteeeemmmmpppp as any  part  of
  1298.  
  1299. their  name.   As  a special case, **** by itself matches every
  1300.  
  1301. filename, so
  1302.  
  1303.  
  1304.   pppprrrr ****
  1305.  
  1306. prints all your files (alphabetical order), and
  1307.  
  1308.  
  1309.   rrrrmmmm ****
  1310.  
  1311. removes _a_l_l _f_i_l_e_s.  (You had better be _v_e_r_y sure that's what
  1312.  
  1313. you wanted to say!)
  1314.  
  1315.  
  1316.  
  1317.  
  1318.                      November 16, 1985
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        21
  1326.  
  1327.  
  1328.   The **** is not the only pattern-matching feature  available.
  1329.  
  1330. Suppose  you  want to print only chapters 1 through 4 and 9.
  1331.  
  1332. Then you can say
  1333.  
  1334.  
  1335.   pppprrrr cccchhhhaaaapppp[[[[11112222333344449999]]]]****
  1336.  
  1337. The [[[[............]]]] means to match any of the  characters  inside  the
  1338.  
  1339. brackets.   A  range of consecutive letters or digits can be
  1340.  
  1341. abbreviated, so you can also do this with
  1342.  
  1343.  
  1344.   pppprrrr cccchhhhaaaapppp[[[[1111----44449999]]]]****
  1345.  
  1346. Letters can also be used within brackets: [[[[aaaa----zzzz]]]] matches  any
  1347.  
  1348. character in the range aaaa through zzzz.
  1349.  
  1350.  
  1351.   The ???? pattern matches any single character, so
  1352.  
  1353.  
  1354.   llllssss ????
  1355.  
  1356. lists all files which have single-character names, and
  1357.  
  1358.  
  1359.   llllssss ----llll cccchhhhaaaapppp????....1111
  1360.  
  1361. lists information about  the  first  file  of  each  chapter
  1362.  
  1363. (cccchhhhaaaapppp1111....1111, cccchhhhaaaapppp2222....1111, etc.).
  1364.  
  1365.  
  1366.   Of these niceties, **** is certainly the most useful, and you
  1367.  
  1368. should  get  used  to  it.  The others are frills, but worth
  1369.  
  1370. knowing.
  1371.  
  1372.  
  1373.   If you should ever have to turn off the special meaning of
  1374.  
  1375. ****, ????, etc., enclose the entire argument in single quotes, as
  1376.  
  1377. in
  1378.  
  1379.  
  1380.   llllssss ''''????''''
  1381.  
  1382.  
  1383.  
  1384.                      November 16, 1985
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391. 22                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  1392.  
  1393.  
  1394. We'll see some more examples of this shortly.
  1395.  
  1396.  
  1397. _W_h_a_t'_s _i_n _a _F_i_l_e_n_a_m_e, _C_o_n_t_i_n_u_e_d
  1398.  
  1399.  
  1400.   When you first made that file called  jjjjuuuunnnnkkkk,  how  did  the
  1401.  
  1402. system  know  that there wasn't another jjjjuuuunnnnkkkk somewhere else,
  1403.  
  1404. especially since the person in the next office is also read-
  1405.  
  1406. ing  this  tutorial?  The answer is that generally each user
  1407.  
  1408. has a private _d_i_r_e_c_t_o_r_y, which contains only the files  that
  1409.  
  1410. belong  to him.  When you log in, you are ``in'' your direc-
  1411.  
  1412. tory.  Unless you take special action, when you create a new
  1413.  
  1414. file, it is made in the directory that you are currently in;
  1415.  
  1416. this is most often your own directory, and thus the file  is
  1417.  
  1418. unrelated  to  any  other  file  of the same name that might
  1419.  
  1420. exist in someone else's directory.
  1421.  
  1422.  
  1423.   The set of all files is organized  into  a  (usually  big)
  1424.  
  1425. tree,  with  your  files  located  several branches into the
  1426.  
  1427. tree.  It is possible for you to ``walk'' around this  tree,
  1428.  
  1429. and  to find any file in the system, by starting at the root
  1430.  
  1431. of the tree and walking along the proper  set  of  branches.
  1432.  
  1433. Conversely,  you can start where you are and walk toward the
  1434.  
  1435. root.
  1436.  
  1437.  
  1438.   Let's try the latter first.  The basic tools is  the  com-
  1439.  
  1440. mand  ppppwwwwdddd  (``print  working  directory''), which prints the
  1441.  
  1442. name of the directory you are currently in.
  1443.  
  1444.  
  1445.   Although the details will vary according to the system you
  1446.  
  1447. are on, if you give the command ppppwwwwdddd, it will print something
  1448.  
  1449.  
  1450.                      November 16, 1985
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        23
  1458.  
  1459.  
  1460. like
  1461.  
  1462.  
  1463.   ////uuuussssrrrr////yyyyoooouuuurrrr----nnnnaaaammmmeeee
  1464.  
  1465. This says that you are currently in the directory yyyyoooouuuurrrr----nnnnaaaammmmeeee,
  1466.  
  1467. which  is in turn in the directory ////uuuussssrrrr, which is in turn in
  1468.  
  1469. the root directory called by convention just  ////.   (Even  if
  1470.  
  1471. it's  not called ////uuuussssrrrr on your system, you will get something
  1472.  
  1473. analogous.  Make the corresponding changes and read on.)
  1474.  
  1475.  
  1476.   If you now type
  1477.  
  1478.  
  1479.   llllssss ////uuuussssrrrr////yyyyoooouuuurrrr----nnnnaaaammmmeeee
  1480.  
  1481. you should get exactly the same list of file  names  as  you
  1482.  
  1483. get  from  a  plain llllssss: with no arguments, llllssss lists the con-
  1484.  
  1485. tents of the current directory; given the name of  a  direc-
  1486.  
  1487. tory, it lists the contents of that directory.
  1488.  
  1489.  
  1490.   Next, try
  1491.  
  1492.  
  1493.   llllssss ////uuuussssrrrr
  1494.  
  1495. This should print a long series of  names,  among  which  is
  1496.  
  1497. your  own  login  name yyyyoooouuuurrrr----nnnnaaaammmmeeee.  On many systems, uuuussssrrrr is a
  1498.  
  1499. directory that contains the directories of  all  the  normal
  1500.  
  1501. users of the system, like you.
  1502.  
  1503.  
  1504.   The next step is to try
  1505.  
  1506.  
  1507.   llllssss ////
  1508.  
  1509. You should get a  response  something  like  this  (although
  1510.  
  1511. again the details may be different):
  1512.  
  1513.  
  1514.  
  1515.  
  1516.                      November 16, 1985
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523. 24                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  1524.  
  1525.  
  1526.  
  1527.   bbbbiiiinnnn
  1528.   ddddeeeevvvv
  1529.   eeeettttcccc
  1530.   lllliiiibbbb
  1531.   ttttmmmmpppp
  1532.   uuuussssrrrr
  1533.  
  1534. This is a collection of the basic directories of files  that
  1535.  
  1536. the system knows about; we are at the root of the tree.
  1537.  
  1538.  
  1539.   Now try
  1540.  
  1541.  
  1542.   ccccaaaatttt ////uuuussssrrrr////yyyyoooouuuurrrr----nnnnaaaammmmeeee////jjjjuuuunnnnkkkk
  1543.  
  1544. (if jjjjuuuunnnnkkkk is still around in your directory).  The name
  1545.  
  1546.  
  1547.   ////uuuussssrrrr////yyyyoooouuuurrrr----nnnnaaaammmmeeee////jjjjuuuunnnnkkkk
  1548.  
  1549. is called the ppppaaaatttthhhhnnnnaaaammmmeeee of the file that you  normally  think
  1550.  
  1551. of  as  ``junk''.   ``Pathname''  has an obvious meaning: it
  1552.  
  1553. represents the full name of the path you have to follow from
  1554.  
  1555. the root through the tree of directories to get to a partic-
  1556.  
  1557. ular file.  It is a universal rule in the UNIX  system  that
  1558.  
  1559. anywhere  you  can  use  an ordinary filename, you can use a
  1560.  
  1561. pathname.
  1562.  
  1563.  
  1564.   Here is a picture which may make this clearer:
  1565.  
  1566.  
  1567.                             (root)
  1568.                             / | \
  1569.                            /  |  \
  1570.                           /   |   \
  1571.                 bin    etc    usr    dev   tmp
  1572.             / | \   / | \   / | \   / | \   / | \
  1573.                            /  |  \
  1574.                           /   |   \
  1575.                        adam  eve   mary
  1576.                    /        /   \        \
  1577.                             /     \       junk
  1578.                           junk temp
  1579.  
  1580.  
  1581.  
  1582.                      November 16, 1985
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        25
  1590.  
  1591.  
  1592. Notice that Mary's jjjjuuuunnnnkkkk is unrelated to Eve's.
  1593.  
  1594.  
  1595.   This isn't too exciting if all the files of  interest  are
  1596.  
  1597. in  your own directory, but if you work with someone else or
  1598.  
  1599. on several projects concurrently, it becomes  handy  indeed.
  1600.  
  1601. For example, your friends can print your book by saying
  1602.  
  1603.  
  1604.   pppprrrr ////uuuussssrrrr////yyyyoooouuuurrrr----nnnnaaaammmmeeee////cccchhhhaaaapppp****
  1605.  
  1606. Similarly, you can find out what files your neighbor has  by
  1607.  
  1608. saying
  1609.  
  1610.  
  1611.   llllssss ////uuuussssrrrr////nnnneeeeiiiigggghhhhbbbboooorrrr----nnnnaaaammmmeeee
  1612.  
  1613. or make your own copy of one of his files by
  1614.  
  1615.  
  1616.   ccccpppp ////uuuussssrrrr////yyyyoooouuuurrrr----nnnneeeeiiiigggghhhhbbbboooorrrr////hhhhiiiissss----ffffiiiilllleeee yyyyoooouuuurrrrffffiiiilllleeee
  1617.  
  1618.  
  1619.   If your neighbor doesn't want you  poking  around  in  his
  1620.  
  1621. files,  or  vice  versa, privacy can be arranged.  Each file
  1622.  
  1623. and directory has  read-write-execute  permissions  for  the
  1624.  
  1625. owner,  a group, and everyone else, which can be set to con-
  1626.  
  1627. trol access.  See llllssss(1) and  cccchhhhmmmmoooodddd(1)  for  details.   As  a
  1628.  
  1629. matter  of  observed  fact, most users most of the time find
  1630.  
  1631. openness of more benefit than privacy.
  1632.  
  1633.  
  1634.   As a final experiment with pathnames, try
  1635.  
  1636.  
  1637.   llllssss ////bbbbiiiinnnn ////uuuussssrrrr////bbbbiiiinnnn
  1638.  
  1639. Do some of the names look familiar?  When you run a program,
  1640.  
  1641. by  typing  its  name after the prompt character, the system
  1642.  
  1643. simply looks for a file of that  name.   It  normally  looks
  1644.  
  1645. first  in  your  directory  (where it typically doesn't find
  1646.  
  1647.  
  1648.                      November 16, 1985
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655. 26                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  1656.  
  1657.  
  1658. it), then in ////bbbbiiiinnnn and finally in ////uuuussssrrrr////bbbbiiiinnnn.  There is nothing
  1659.  
  1660. magic  about  commands like ccccaaaatttt or llllssss, except that they have
  1661.  
  1662. been collected into a couple of places to be  easy  to  find
  1663.  
  1664. and administer.
  1665.  
  1666.  
  1667.   What if you work regularly with  someone  else  on  common
  1668.  
  1669. information in his directory?  You could just log in as your
  1670.  
  1671. friend each time you want to, but you can also say ``I  want
  1672.  
  1673. to  work  on his files instead of my own''.  This is done by
  1674.  
  1675. changing the directory that you are currently in:
  1676.  
  1677.  
  1678.   ccccdddd ////uuuussssrrrr////yyyyoooouuuurrrr----ffffrrrriiiieeeennnndddd
  1679.  
  1680. (On some systems, ccccdddd is spelled cccchhhhddddiiiirrrr.) Now when you  use  a
  1681.  
  1682. filename  in something like ccccaaaatttt or pppprrrr, it refers to the file
  1683.  
  1684. in your friend's directory.   Changing  directories  doesn't
  1685.  
  1686. affect  any  permissions  associated  with  a  file - if you
  1687.  
  1688. couldn't access a file from your own directory, changing  to
  1689.  
  1690. another  directory won't alter that fact.  Of course, if you
  1691.  
  1692. forget what directory you're in, type
  1693.  
  1694.  
  1695.   ppppwwwwdddd
  1696.  
  1697. to find out.
  1698.  
  1699.  
  1700.   It is usually convenient to arrange your own files so that
  1701.  
  1702. all  the  files  related  to  one  thing  are in a directory
  1703.  
  1704. separate from other projects.  For example, when  you  write
  1705.  
  1706. your  book,  you might want to keep all the text in a direc-
  1707.  
  1708. tory called bbbbooooooookkkk.  So make one with
  1709.  
  1710.  
  1711.   mmmmkkkkddddiiiirrrr bbbbooooooookkkk
  1712.  
  1713.  
  1714.                      November 16, 1985
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        27
  1722.  
  1723.  
  1724. then go to it with
  1725.  
  1726.  
  1727.   ccccdddd bbbbooooooookkkk
  1728.  
  1729. then start typing  chapters.   The  book  is  now  found  in
  1730.  
  1731. (presumably)
  1732.  
  1733.  
  1734.   ////uuuussssrrrr////yyyyoooouuuurrrr----nnnnaaaammmmeeee////bbbbooooooookkkk
  1735.  
  1736. To remove the directory bbbbooooooookkkk, type
  1737.  
  1738.  
  1739.   rrrrmmmm bbbbooooooookkkk////****
  1740.   rrrrmmmmddddiiiirrrr bbbbooooooookkkk
  1741.  
  1742. The first command removes all files from the directory;  the
  1743.  
  1744. second removes the empty directory.
  1745.  
  1746.  
  1747.   You can go up one level in the tree of files by saying
  1748.  
  1749.  
  1750.   ccccdddd ........
  1751.  
  1752. ``........'' is the name of the parent of whatever  directory  you
  1753.  
  1754. are  currently  in.  For completeness, ``....'' is an alternate
  1755.  
  1756. name for the directory you are in.
  1757.  
  1758.  
  1759. _U_s_i_n_g _F_i_l_e_s _i_n_s_t_e_a_d _o_f _t_h_e _T_e_r_m_i_n_a_l
  1760.  
  1761.  
  1762.   Most of the commands we have seen so far produce output on
  1763.  
  1764. the  terminal;  some, like the editor, also take their input
  1765.  
  1766. from the terminal.  It is universal in UNIX systems that the
  1767.  
  1768. terminal  can  be  replaced  by a file for either or both of
  1769.  
  1770. input and output.  As one example,
  1771.  
  1772.  
  1773.   llllssss
  1774.  
  1775. makes a list of files on your terminal.  But if you say
  1776.  
  1777.  
  1778.  
  1779.  
  1780.                      November 16, 1985
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787. 28                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  1788.  
  1789.  
  1790.  
  1791.   llllssss >>>>ffffiiiilllleeeelllliiiisssstttt
  1792.  
  1793. a list of your files will be placed  in  the  file  ffffiiiilllleeeelllliiiisssstttt
  1794.  
  1795. (which  will  be  created  if  it  doesn't already exist, or
  1796.  
  1797. overwritten if it does).  The symbol >>>> means ``put the  out-
  1798.  
  1799. put  on  the  following file, rather than on the terminal.''
  1800.  
  1801. Nothing is produced on the terminal.   As  another  example,
  1802.  
  1803. you  could  combine  several files into one by capturing the
  1804.  
  1805. output of ccccaaaatttt in a file:
  1806.  
  1807.  
  1808.   ccccaaaatttt ffff1111 ffff2222 ffff3333 >>>>tttteeeemmmmpppp
  1809.  
  1810.  
  1811.   The symbol >>>>>>>> operates very much like >>>> does, except  that
  1812.  
  1813. it means ``add to the end of.'' That is,
  1814.  
  1815.  
  1816.   ccccaaaatttt ffff1111 ffff2222 ffff3333 >>>>>>>>tttteeeemmmmpppp
  1817.  
  1818. means to concatenate ffff1111, ffff2222 and ffff3333 to the end of whatever is
  1819.  
  1820. already  in  tttteeeemmmmpppp,  instead of overwriting the existing con-
  1821.  
  1822. tents.  As with >>>>, if tttteeeemmmmpppp doesn't exist, it will be created
  1823.  
  1824. for you.
  1825.  
  1826.  
  1827.   In a similar way, the symbol <<<< means to take the input for
  1828.  
  1829. a  program from the following file, instead of from the ter-
  1830.  
  1831. minal.  Thus, you could make up a script  of  commonly  used
  1832.  
  1833. editing  commands  and  put  them into a file called ssssccccrrrriiiipppptttt.
  1834.  
  1835. Then you can run the script on a file by saying
  1836.  
  1837.  
  1838.   eeeedddd ffffiiiilllleeee <<<<ssssccccrrrriiiipppptttt
  1839.  
  1840. As another example, you can use eeeedddd to prepare  a  letter  in
  1841.  
  1842. file lllleeeetttt, then send it to several people with
  1843.  
  1844.  
  1845.  
  1846.                      November 16, 1985
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        29
  1854.  
  1855.  
  1856.  
  1857.   mmmmaaaaiiiillll aaaaddddaaaammmm eeeevvvveeee mmmmaaaarrrryyyy jjjjooooeeee <<<<lllleeeetttt
  1858.  
  1859.  
  1860. _P_i_p_e_s
  1861.  
  1862.  
  1863.   One of the novel contributions of the UNIX system  is  the
  1864.  
  1865. idea  of a _p_i_p_e.  A pipe is simply a way to connect the out-
  1866.  
  1867. put of one program to the input of another program,  so  the
  1868.  
  1869. two run as a sequence of processes - a pipeline.
  1870.  
  1871.  
  1872.   For example,
  1873.  
  1874.  
  1875.   pppprrrr ffff gggg hhhh
  1876.  
  1877. will print the files ffff, gggg, and hhhh, beginning each  on  a  new
  1878.  
  1879. page.   Suppose  you  want  them  run together instead.  You
  1880.  
  1881. could say
  1882.  
  1883.  
  1884.   ccccaaaatttt ffff gggg hhhh >>>>tttteeeemmmmpppp
  1885.   pppprrrr <<<<tttteeeemmmmpppp
  1886.   rrrrmmmm tttteeeemmmmpppp
  1887.  
  1888. but this is more work than necessary.  Clearly what we  want
  1889.  
  1890. is  to take the output of ccccaaaatttt and connect it to the input of
  1891.  
  1892. pppprrrr.  So let us use a pipe:
  1893.  
  1894.  
  1895.   ccccaaaatttt ffff gggg hhhh |||| pppprrrr
  1896.  
  1897. The vertical bar |||| means to take the output from ccccaaaatttt,  which
  1898.  
  1899. would normally have gone to the terminal, and put it into pppprrrr
  1900.  
  1901. to be neatly formatted.
  1902.  
  1903.  
  1904.   There are many other examples of pipes.  For example,
  1905.  
  1906.  
  1907.   llllssss |||| pppprrrr ----3333
  1908.  
  1909. prints a list of your files in three columns.   The  program
  1910.  
  1911.  
  1912.                      November 16, 1985
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919. 30                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  1920.  
  1921.  
  1922. wwwwcccc  counts  the number of lines, words and characters in its
  1923.  
  1924. input,  and  as  we  saw  earlier,  wwwwhhhhoooo  prints  a  list  of
  1925.  
  1926. currently-logged on people, one per line.  Thus
  1927.  
  1928.  
  1929.   wwwwhhhhoooo |||| wwwwcccc
  1930.  
  1931. tells how many people are logged on.  And of course
  1932.  
  1933.  
  1934.   llllssss |||| wwwwcccc
  1935.  
  1936. counts your files.
  1937.  
  1938.  
  1939.   Any program that reads from the terminal can read  from  a
  1940.  
  1941. pipe  instead;  any  program that writes on the terminal can
  1942.  
  1943. drive a pipe.  You can have as many elements in  a  pipeline
  1944.  
  1945. as you wish.
  1946.  
  1947.  
  1948.   Many UNIX programs are written  so  that  they  will  take
  1949.  
  1950. their  input  from  one  or more files if file arguments are
  1951.  
  1952. given; if no arguments are given they  will  read  from  the
  1953.  
  1954. terminal,  and  thus  can  be  used in pipelines.  pppprrrr is one
  1955.  
  1956. example:
  1957.  
  1958.  
  1959.   pppprrrr ----3333 aaaa bbbb cccc
  1960.  
  1961. prints files aaaa, bbbb and cccc in order in three columns.  But in
  1962.  
  1963.  
  1964.   ccccaaaatttt aaaa bbbb cccc |||| pppprrrr ----3333
  1965.  
  1966. pppprrrr prints the information coming down the pipeline, still in
  1967.  
  1968. three columns.
  1969.  
  1970.  
  1971. _T_h_e _S_h_e_l_l
  1972.  
  1973.  
  1974.   We have already mentioned once  or  twice  the  mysterious
  1975.  
  1976.  
  1977.  
  1978.                      November 16, 1985
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        31
  1986.  
  1987.  
  1988. ``shell,'' which is in fact sssshhhh(1).  The shell is the program
  1989.  
  1990. that interprets what you type as commands and arguments.  It
  1991.  
  1992. also   looks  after  translating  ****,  etc.,  into  lists  of
  1993.  
  1994. filenames, and <<<<, >>>>, and |||| into changes of input and  output
  1995.  
  1996. streams.
  1997.  
  1998.  
  1999.   The shell has other capabilities too.   For  example,  you
  2000.  
  2001. can run two programs with one command line by separating the
  2002.  
  2003. commands with a semicolon; the shell  recognizes  the  semi-
  2004.  
  2005. colon and breaks the line into two commands.  Thus
  2006.  
  2007.  
  2008.   ddddaaaatttteeee;;;; wwwwhhhhoooo
  2009.  
  2010. does both commands before returning with a prompt character.
  2011.  
  2012.  
  2013.   You can also have more than one program running _s_i_m_u_l_t_a_n_e_-
  2014.  
  2015. _o_u_s_l_y  if you wish.  For example, if you are doing something
  2016.  
  2017. time-consuming, like the editor script of  an  earlier  sec-
  2018.  
  2019. tion,  and  you  don't  want  to wait around for the results
  2020.  
  2021. before starting something else, you can say
  2022.  
  2023.  
  2024.   eeeedddd ffffiiiilllleeee <<<<ssssccccrrrriiiipppptttt &&&&
  2025.  
  2026. The ampersand at the end of a command line says ``start this
  2027.  
  2028. command  running, then take further commands from the termi-
  2029.  
  2030. nal immediately,'' that is, don't wait for it  to  complete.
  2031.  
  2032. Thus the script will begin, but you can do something else at
  2033.  
  2034. the same time.  Of course, to keep the output from interfer-
  2035.  
  2036. ing  with  what  you're  doing  on the terminal, it would be
  2037.  
  2038. better to say
  2039.  
  2040.  
  2041.   eeeedddd ffffiiiilllleeee <<<<ssssccccrrrriiiipppptttt >>>>ssssccccrrrriiiipppptttt....oooouuuutttt &&&&
  2042.  
  2043.  
  2044.                      November 16, 1985
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051. 32                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  2052.  
  2053.  
  2054. which saves the output lines in a file called ssssccccrrrriiiipppptttt....oooouuuutttt.
  2055.  
  2056.  
  2057.   When you initiate a command with  &&&&,  the  system  replies
  2058.  
  2059. with  a  number  called the process number, which identifies
  2060.  
  2061. the command in case you later want to stop it.  If  you  do,
  2062.  
  2063. you can say
  2064.  
  2065.  
  2066.   kkkkiiiillllllll pppprrrroooocccceeeessssssss----nnnnuuuummmmbbbbeeeerrrr
  2067.  
  2068. If you forget the process number, the command ppppssss  will  tell
  2069.  
  2070. you   about  everything  you  have  running.   (If  you  are
  2071.  
  2072. desperate, kkkkiiiillllllll 0000 will kill  all  your  processes.)  And  if
  2073.  
  2074. you're  curious about other people, ppppssss aaaa will tell you about
  2075.  
  2076. _a_l_l programs that are currently running.
  2077.  
  2078.  
  2079.   You can say
  2080.  
  2081.  
  2082.   ((((ccccoooommmmmmmmaaaannnndddd----1111;;;; ccccoooommmmmmmmaaaannnndddd----2222;;;; ccccoooommmmmmmmaaaannnndddd----3333)))) &&&&
  2083.  
  2084. to start three commands in the background, or you can  start
  2085.  
  2086. a background pipeline with
  2087.  
  2088.  
  2089.   ccccoooommmmmmmmaaaannnndddd----1111 |||| ccccoooommmmmmmmaaaannnndddd----2222 &&&&
  2090.  
  2091.  
  2092.   Just as you can tell the editor or some similar program to
  2093.  
  2094. take its input from a file instead of from the terminal, you
  2095.  
  2096. can tell the shell to read a file  to  get  commands.   (Why
  2097.  
  2098. not?  The  shell,  after  all,  is  just a program, albeit a
  2099.  
  2100. clever one.) For instance, suppose you want to set  tabs  on
  2101.  
  2102. your terminal, and find out the date and who's on the system
  2103.  
  2104. every time you log in.  Then you can put the three necessary
  2105.  
  2106. commands  (ttttaaaabbbbssss,  ddddaaaatttteeee,  wwwwhhhhoooo)  into  a  file,  let's call it
  2107.  
  2108.  
  2109.  
  2110.                      November 16, 1985
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        33
  2118.  
  2119.  
  2120. ssssttttaaaarrrrttttuuuupppp, and then run it with
  2121.  
  2122.  
  2123.   sssshhhh ssssttttaaaarrrrttttuuuupppp
  2124.  
  2125. This says to run the shell with the file ssssttttaaaarrrrttttuuuupppp  as  input.
  2126.  
  2127. The effect is as if you had typed the contents of ssssttttaaaarrrrttttuuuupppp on
  2128.  
  2129. the terminal.
  2130.  
  2131.  
  2132.   If this is to be a regular thing, you  can  eliminate  the
  2133.  
  2134. need to type sssshhhh: simply type, once only, the command
  2135.  
  2136.  
  2137.   cccchhhhmmmmoooodddd ++++xxxx ssssttttaaaarrrrttttuuuupppp
  2138.  
  2139. and thereafter you need only say
  2140.  
  2141.  
  2142.   ssssttttaaaarrrrttttuuuupppp
  2143.  
  2144. to run the sequence of commands.  The cccchhhhmmmmoooodddd(1) command marks
  2145.  
  2146. the  file  executable; the shell recognizes this and runs it
  2147.  
  2148. as a sequence of commands.
  2149.  
  2150.  
  2151.   If you want ssssttttaaaarrrrttttuuuupppp to run automatically  every  time  you
  2152.  
  2153. log  in,  create  a  file  in  your  login  directory called
  2154.  
  2155. ....pppprrrrooooffffiiiilllleeee, and place in it the line ssssttttaaaarrrrttttuuuupppp.  When the  shell
  2156.  
  2157. first  gains  control  when  you  log  in,  it looks for the
  2158.  
  2159. ....pppprrrrooooffffiiiilllleeee file and does whatever commands  it  finds  in  it.
  2160.  
  2161. We'll get back to the shell in the section on programming.
  2162.  
  2163.  
  2164.  
  2165. _I_I_I. _D_O_C_U_M_E_N_T _P_R_E_P_A_R_A_T_I_O_N
  2166.  
  2167.  
  2168.   UNIX systems are used extensively  for  document  prepara-
  2169.  
  2170. tion.   There  are  two  major formatting programs, that is,
  2171.  
  2172. programs that produce a text with justified  right  margins,
  2173.  
  2174.  
  2175.  
  2176.                      November 16, 1985
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183. 34                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  2184.  
  2185.  
  2186. automatic page numbering and titling, automatic hyphenation,
  2187.  
  2188. and the like.  nnnnrrrrooooffffffff is designed to produce output on termi-
  2189.  
  2190. nals  and  line-printers.   ttttrrrrooooffffffff  (pronounced ``tee-roff'')
  2191.  
  2192. instead drives a phototypesetter, which produces  very  high
  2193.  
  2194. quality  output  on photographic paper.  This paper was for-
  2195.  
  2196. matted with ttttrrrrooooffffffff.
  2197.  
  2198.  
  2199. _F_o_r_m_a_t_t_i_n_g _P_a_c_k_a_g_e_s
  2200.  
  2201.  
  2202.   The basic idea of nnnnrrrrooooffffffff and ttttrrrrooooffffffff is that the text  to  be
  2203.  
  2204. formatted  contains  within  it ``formatting commands'' that
  2205.  
  2206. indicate in detail how the formatted text is to  look.   For
  2207.  
  2208. example, there might be commands that specify how long lines
  2209.  
  2210. are, whether to use single or double spacing, and what  run-
  2211.  
  2212. ning titles to use on each page.
  2213.  
  2214.  
  2215.   Because nnnnrrrrooooffffffff and ttttrrrrooooffffffff are relatively hard  to  learn  to
  2216.  
  2217. use  effectively,  several ``packages'' of canned formatting
  2218.  
  2219. requests are available to let you specify  paragraphs,  run-
  2220.  
  2221. ning titles, footnotes, multi-column output, and so on, with
  2222.  
  2223. little effort and without having to learn nnnnrrrrooooffffffff  and  ttttrrrrooooffffffff.
  2224.  
  2225. These  packages  take  a  modest  effort  to  learn, but the
  2226.  
  2227. rewards for using them are so great that  it  is  time  well
  2228.  
  2229. spent.
  2230.  
  2231.  
  2232.   In this section, we will  provide  a  hasty  look  at  the
  2233.  
  2234. ``manuscript''  package  known  as ----mmmmssss.  Formatting requests
  2235.  
  2236. typically consist of a period and  two  upper-case  letters,
  2237.  
  2238. such  as  ....TTTTLLLL, which is used to introduce a title, or ....PPPPPPPP to
  2239.  
  2240.  
  2241.  
  2242.                      November 16, 1985
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        35
  2250.  
  2251.  
  2252. begin a new paragraph.
  2253.  
  2254.  
  2255.   A document is typed so it looks something like this:
  2256.  
  2257.  
  2258.   ....TTTTLLLL
  2259.   ttttiiiittttlllleeee ooooffff ddddooooccccuuuummmmeeeennnntttt
  2260.   ....AAAAUUUU
  2261.   aaaauuuutttthhhhoooorrrr nnnnaaaammmmeeee
  2262.   ....SSSSHHHH
  2263.   sssseeeeccccttttiiiioooonnnn hhhheeeeaaaaddddiiiinnnngggg
  2264.   ....PPPPPPPP
  2265.   ppppaaaarrrraaaaggggrrrraaaapppphhhh ............
  2266.   ....PPPPPPPP
  2267.   aaaannnnooootttthhhheeeerrrr ppppaaaarrrraaaaggggrrrraaaapppphhhh ............
  2268.   ....SSSSHHHH
  2269.   aaaannnnooootttthhhheeeerrrr sssseeeeccccttttiiiioooonnnn hhhheeeeaaaaddddiiiinnnngggg
  2270.   ....PPPPPPPP
  2271.   eeeettttcccc....
  2272.  
  2273. The lines that  begin  with  a  period  are  the  formatting
  2274.  
  2275. requests.   For  example, ....PPPPPPPP calls for starting a new para-
  2276.  
  2277. graph.  The precise meaning of ....PPPPPPPP depends  on  what  output
  2278.  
  2279. device is being used (typesetter or terminal, for instance),
  2280.  
  2281. and on what publication the document will  appear  in.   For
  2282.  
  2283. example,  ----mmmmssss  normally assumes that a paragraph is preceded
  2284.  
  2285. by a space (one line in nnnnrrrrooooffffffff, 1/2 line in ttttrrrrooooffffffff),  and  the
  2286.  
  2287. first  word  is indented.  These rules can be changed if you
  2288.  
  2289. like, but they are changed by changing the interpretation of
  2290.  
  2291. ....PPPPPPPP, not by re-typing the document.
  2292.  
  2293.  
  2294.   To actually produce a document in  standard  format  using
  2295.  
  2296. ----mmmmssss, use the command
  2297.  
  2298.  
  2299.   ttttrrrrooooffffffff ----mmmmssss ffffiiiilllleeeessss ............
  2300.  
  2301. for the typesetter, and
  2302.  
  2303.  
  2304.   nnnnrrrrooooffffffff ----mmmmssss ffffiiiilllleeeessss ............
  2305.  
  2306.  
  2307.  
  2308.                      November 16, 1985
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315. 36                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  2316.  
  2317.  
  2318. for a terminal.  The ----mmmmssss argument tells ttttrrrrooooffffffff and  nnnnrrrrooooffffffff  to
  2319.  
  2320. use the manuscript package of formatting requests.
  2321.  
  2322.  
  2323.   There are several similar packages;  check  with  a  local
  2324.  
  2325. expert  to  determine  which  ones are in common use on your
  2326.  
  2327. machine.
  2328.  
  2329.  
  2330. _S_u_p_p_o_r_t_i_n_g _T_o_o_l_s
  2331.  
  2332.  
  2333.   In addition to the basic formatters, there is  a  host  of
  2334.  
  2335. supporting  programs  that  help  with document preparation.
  2336.  
  2337. The list in the next few paragraphs is far from complete, so
  2338.  
  2339. browse  through  the manual and check with people around you
  2340.  
  2341. for other possibilities.
  2342.  
  2343.  
  2344.   eeeeqqqqnnnn and nnnneeeeqqqqnnnn let you integrate mathematics into  the  text
  2345.  
  2346. of  a  document,  in  an easy-to-learn language that closely
  2347.  
  2348. resembles the way you would speak it  aloud.   For  example,
  2349.  
  2350. the eeeeqqqqnnnn input
  2351.  
  2352.  
  2353.   ssssuuuummmm ffffrrrroooommmm iiii====0000 ttttoooo nnnn xxxx ssssuuuubbbb iiii ~~~~====~~~~ ppppiiii oooovvvveeeerrrr 2222
  2354.  
  2355. produces the output
  2356.  
  2357.  
  2358.  
  2359.                          _i_=0_R_n _x_i _= 2_J__
  2360.  
  2361.  
  2362.   The program ttttbbbbllll provides an analogous service for  prepar-
  2363.  
  2364. ing tabular material; it does all the computations necessary
  2365.  
  2366. to  align  complicated  columns  with  elements  of  varying
  2367.  
  2368. widths.
  2369.  
  2370.  
  2371.  
  2372.  
  2373.                      November 16, 1985
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        37
  2381.  
  2382.  
  2383.   rrrreeeeffffeeeerrrr prepares bibliographic citations from a  data  base,
  2384.  
  2385. in  whatever style is defined by the formatting package.  It
  2386.  
  2387. looks after all  the  details  of  numbering  references  in
  2388.  
  2389. sequence,  filling  in  page and volume numbers, getting the
  2390.  
  2391. author's initials and the journal name right, and so on.
  2392.  
  2393.  
  2394.   ssssppppeeeellllllll and ttttyyyyppppoooo detect  possible  spelling  mistakes  in  a
  2395.  
  2396. document.   ssssppppeeeellllllll works by comparing the words in your docu-
  2397.  
  2398. ment to a dictionary, printing those that  are  not  in  the
  2399.  
  2400. dictionary.   It  knows  enough  about  English  spelling to
  2401.  
  2402. detect plurals and the like, so it does  a  very  good  job.
  2403.  
  2404. ttttyyyyppppoooo  looks  for  words  which  are  ``unusual'', and prints
  2405.  
  2406. those.  Spelling mistakes tend to be more unusual, and  thus
  2407.  
  2408. show up early when the most unusual words are printed first.
  2409.  
  2410.  
  2411.   ggggrrrreeeepppp looks through a set of files for lines that contain a
  2412.  
  2413. particular  text  pattern  (rather like the editor's context
  2414.  
  2415. search does, but on a bunch of files).  For example,
  2416.  
  2417.  
  2418.   ggggrrrreeeepppp ''''iiiinnnngggg$$$$'''' cccchhhhaaaapppp****
  2419.  
  2420. will find all lines that end with the  letters  iiiinnnngggg  in  the
  2421.  
  2422. files  cccchhhhaaaapppp****.   (It  is almost always a good practice to put
  2423.  
  2424. single quotes around the pattern you're  searching  for,  in
  2425.  
  2426. case  it contains characters like **** or $$$$ that have a special
  2427.  
  2428. meaning to the shell.) ggggrrrreeeepppp is often useful for finding  out
  2429.  
  2430. in  which of a set of files the misspelled words detected by
  2431.  
  2432. ssssppppeeeellllllll are actually located.
  2433.  
  2434.  
  2435.   ddddiiiiffffffff prints a list of the differences between  two  files,
  2436.  
  2437.  
  2438.  
  2439.                      November 16, 1985
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446. 38                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  2447.  
  2448.  
  2449. so  you  can compare two versions of something automatically
  2450.  
  2451. (which certainly beats proofreading by hand).
  2452.  
  2453.  
  2454.   wwwwcccc counts the words, lines and  characters  in  a  set  of
  2455.  
  2456. files.   ttttrrrr translates characters into other characters; for
  2457.  
  2458. example it will convert upper to lower case and vice  versa.
  2459.  
  2460. This translates upper into lower:
  2461.  
  2462.  
  2463.   ttttrrrr AAAA----ZZZZ aaaa----zzzz <<<<iiiinnnnppppuuuutttt >>>>oooouuuuttttppppuuuutttt
  2464.  
  2465.  
  2466.   ssssoooorrrrtttt sorts files in a variety of ways; ccccrrrreeeeffff  makes  cross-
  2467.  
  2468. references;  ppppttttxxxx  makes a permuted index (keyword-in-context
  2469.  
  2470. listing).  sssseeeedddd provides many of the  editing  facilities  of
  2471.  
  2472. eeeedddd, but can apply them to arbitrarily long inputs.  aaaawwwwkkkk pro-
  2473.  
  2474. vides the ability to do both pattern  matching  and  numeric
  2475.  
  2476. computations,  and  to  conveniently  process  fields within
  2477.  
  2478. lines.  These programs are for more advanced users, and they
  2479.  
  2480. are  not  limited to document preparation.  Put them on your
  2481.  
  2482. list of things to learn about.
  2483.  
  2484.  
  2485.   Most of these programs are either independently documented
  2486.  
  2487. (like  eeeeqqqqnnnn  and  ttttbbbbllll),  or  are sufficiently simple that the
  2488.  
  2489. description in the  _U_N_I_X  _P_r_o_g_r_a_m_m_e_r'_s  _M_a_n_u_a_l  is  adequate
  2490.  
  2491. explanation.
  2492.  
  2493.  
  2494. _H_i_n_t_s _f_o_r _P_r_e_p_a_r_i_n_g _D_o_c_u_m_e_n_t_s
  2495.  
  2496.  
  2497.   Most documents go through several  versions  (always  more
  2498.  
  2499. than   you  expected)  before  they  are  finally  finished.
  2500.  
  2501. Accordingly, you should do whatever possible to make the job
  2502.  
  2503.  
  2504.  
  2505.                      November 16, 1985
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        39
  2513.  
  2514.  
  2515. of changing them easy.
  2516.  
  2517.  
  2518.   First, when you do the  purely  mechanical  operations  of
  2519.  
  2520. typing, type so that subsequent editing will be easy.  Start
  2521.  
  2522. each sentence on a new line.  Make lines  short,  and  break
  2523.  
  2524. lines  at  natural  places,  such  as after commas and semi-
  2525.  
  2526. colons, rather than  randomly.   Since  most  people  change
  2527.  
  2528. documents  by  rewriting  phrases  and  adding, deleting and
  2529.  
  2530. rearranging sentences, these precautions simplify any  edit-
  2531.  
  2532. ing you have to do later.
  2533.  
  2534.  
  2535.   Keep the individual files of a  document  down  to  modest
  2536.  
  2537. size,  perhaps  ten  to fifteen thousand characters.  Larger
  2538.  
  2539. files edit more slowly, and of course if  you  make  a  dumb
  2540.  
  2541. mistake  it's  better  to have clobbered a small file than a
  2542.  
  2543. big one.  Split into files  at  natural  boundaries  in  the
  2544.  
  2545. document,  for the same reasons that you start each sentence
  2546.  
  2547. on a new line.
  2548.  
  2549.  
  2550.   The second aspect of making change easy is to  not  commit
  2551.  
  2552. yourself to formatting details too early.  One of the advan-
  2553.  
  2554. tages of formatting packages like ----mmmmssss is  that  they  permit
  2555.  
  2556. you to delay decisions to the last possible moment.  Indeed,
  2557.  
  2558. until a document is printed, it is not even decided  whether
  2559.  
  2560. it will be typeset or put on a line printer.
  2561.  
  2562.  
  2563.   As a rule of thumb, for all but the most trivial jobs, you
  2564.  
  2565. should  type  a  document in terms of a set of requests like
  2566.  
  2567. ....PPPPPPPP, and then define them appropriately, either by using one
  2568.  
  2569.  
  2570.  
  2571.                      November 16, 1985
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578. 40                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  2579.  
  2580.  
  2581. of  the canned packages (the better way) or by defining your
  2582.  
  2583. own nnnnrrrrooooffffffff and ttttrrrrooooffffffff commands.  As long as you  have  entered
  2584.  
  2585. the text in some systematic way, it can always be cleaned up
  2586.  
  2587. and re-formatted by a judicious combination of editing  com-
  2588.  
  2589. mands and request definitions.
  2590.  
  2591.  
  2592. _I_V.  _P_R_O_G_R_A_M_M_I_N_G
  2593.  
  2594.  
  2595.   There will be no attempt made to teach any of the program-
  2596.  
  2597. ming  languages  available  but a few words of advice are in
  2598.  
  2599. order.  One of the reasons why the UNIX system is a  produc-
  2600.  
  2601. tive programming environment is that there is already a rich
  2602.  
  2603. set of tools  available,  and  facilities  like  pipes,  I/O
  2604.  
  2605. redirection, and the capabilities of the shell often make it
  2606.  
  2607. possible to do a  job  by  pasting  together  programs  that
  2608.  
  2609. already exist instead of writing from scratch.
  2610.  
  2611.  
  2612. _T_h_e _S_h_e_l_l
  2613.  
  2614.  
  2615.   The pipe mechanism lets you  fabricate  quite  complicated
  2616.  
  2617. operations out of spare parts that already exist.  For exam-
  2618.  
  2619. ple, the first draft of the ssssppppeeeellllllll program was (roughly)
  2620.  
  2621.  
  2622.   ccccaaaatttt ............     _c_o_l_l_e_c_t _t_h_e _f_i_l_e_s
  2623.   |||| ttttrrrr ............    _p_u_t _e_a_c_h _w_o_r_d _o_n _a _n_e_w _l_i_n_e
  2624.   |||| ttttrrrr ............    _d_e_l_e_t_e _p_u_n_c_t_u_a_t_i_o_n, _e_t_c.
  2625.   |||| ssssoooorrrrtttt      _i_n_t_o _d_i_c_t_i_o_n_a_r_y _o_r_d_e_r
  2626.   |||| uuuunnnniiiiqqqq      _d_i_s_c_a_r_d _d_u_p_l_i_c_a_t_e_s
  2627.   |||| ccccoooommmmmmmm      _p_r_i_n_t _w_o_r_d_s _i_n _t_e_x_t
  2628.           _b_u_t _n_o_t _i_n _d_i_c_t_i_o_n_a_r_y
  2629.  
  2630. More pieces have been added subsequently, but  this  goes  a
  2631.  
  2632. long way for such a small effort.
  2633.  
  2634.  
  2635.  
  2636.  
  2637.                      November 16, 1985
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        41
  2645.  
  2646.  
  2647.   The editor can be made to do things  that  would  normally
  2648.  
  2649. require  special programs on other systems.  For example, to
  2650.  
  2651. list the first and last lines of each of  a  set  of  files,
  2652.  
  2653. such as a book, you could laboriously type
  2654.  
  2655.  
  2656.   eeeedddd
  2657.   eeee cccchhhhaaaapppp1111....1111
  2658.   1111pppp
  2659.   $$$$pppp
  2660.   eeee cccchhhhaaaapppp1111....2222
  2661.   1111pppp
  2662.   $$$$pppp
  2663.   etc.
  2664.  
  2665. But you can do the job much more easily.  One way is to type
  2666.  
  2667.  
  2668.   llllssss cccchhhhaaaapppp**** >>>>tttteeeemmmmpppp
  2669.  
  2670. to get the list of filenames into a file.   Then  edit  this
  2671.  
  2672. file to make the necessary series of editing commands (using
  2673.  
  2674. the global commands of eeeedddd), and write it into  ssssccccrrrriiiipppptttt.   Now
  2675.  
  2676. the command
  2677.  
  2678.  
  2679.   eeeedddd <<<<ssssccccrrrriiiipppptttt
  2680.  
  2681. will produce the same output as the laborious  hand  typing.
  2682.  
  2683. Alternately (and more easily), you can use the fact that the
  2684.  
  2685. shell will perform loops, repeating a set of  commands  over
  2686.  
  2687. and over again for a set of arguments:
  2688.  
  2689.  
  2690.   ffffoooorrrr iiii iiiinnnn cccchhhhaaaapppp****
  2691.   ddddoooo
  2692.        eeeedddd $$$$iiii <<<<ssssccccrrrriiiipppptttt
  2693.   ddddoooonnnneeee
  2694.  
  2695. This sets the shell variable iiii to each file  name  in  turn,
  2696.  
  2697. then  does  the  command.   You can type this command at the
  2698.  
  2699. terminal, or put it in a file for later execution.
  2700.  
  2701.  
  2702.  
  2703.                      November 16, 1985
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710. 42                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  2711.  
  2712.  
  2713. _P_r_o_g_r_a_m_m_i_n_g _t_h_e _S_h_e_l_l
  2714.  
  2715.  
  2716.   An option often overlooked by newcomers is that the  shell
  2717.  
  2718. is  itself  a  programming language, with variables, control
  2719.  
  2720. flow (iiiiffff----eeeellllsssseeee, wwwwhhhhiiiilllleeee, ffffoooorrrr, ccccaaaasssseeee), subroutines, and interrupt
  2721.  
  2722. handling.  Since there are many building-block programs, you
  2723.  
  2724. can sometimes avoid writing a new program merely by  piecing
  2725.  
  2726. together  some  of  the  building  blocks with shell command
  2727.  
  2728. files.
  2729.  
  2730.  
  2731.   We will not go into any details here; examples  and  rules
  2732.  
  2733. can  be found in _A_n _I_n_t_r_o_d_u_c_t_i_o_n _t_o _t_h_e _U_N_I_X _S_h_e_l_l, by S. R.
  2734.  
  2735. Bourne.
  2736.  
  2737.  
  2738. _P_r_o_g_r_a_m_m_i_n_g _i_n _C
  2739.  
  2740.  
  2741.   If you are undertaking anything substantial, C is the only
  2742.  
  2743. reasonable choice of programming language: everything in the
  2744.  
  2745. UNIX system is tuned to it.  The system itself is written in
  2746.  
  2747. C, as are most of the programs that run on it.  It is also a
  2748.  
  2749. easy language to use once you get started.  C is  introduced
  2750.  
  2751. and  fully  described in _T_h_e _C _P_r_o_g_r_a_m_m_i_n_g _L_a_n_g_u_a_g_e by B. W.
  2752.  
  2753. Kernighan and D. M. Ritchie (Prentice-Hall, 1978).   Several
  2754.  
  2755. sections  of the manual describe the system interfaces, that
  2756.  
  2757. is, how you do I/O and similar functions.   Read  _U_N_I_X  _P_r_o_-
  2758.  
  2759. _g_r_a_m_m_i_n_g for more complicated things.
  2760.  
  2761.  
  2762.   Most input and output in C is best handled with the  stan-
  2763.  
  2764. dard I/O library, which provides a set of I/O functions that
  2765.  
  2766. exist in compatible  form  on  most  machines  that  have  C
  2767.  
  2768.  
  2769.                      November 16, 1985
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        43
  2777.  
  2778.  
  2779. compilers.   In  general,  it's wisest to confine the system
  2780.  
  2781. interactions in a program to the facilities provided by this
  2782.  
  2783. library.
  2784.  
  2785.  
  2786.   C programs that don't depend too much on special  features
  2787.  
  2788. of UNIX (such as pipes) can be moved to other computers that
  2789.  
  2790. have C compilers.  The list of such machines grows daily; in
  2791.  
  2792. addition  to  the  original PDP-11, it currently includes at
  2793.  
  2794. least Honeywell 6000, IBM 370, Interdata 8/32, Data  General
  2795.  
  2796. Nova  and  Eclipse,  HP 2100, Harris /7, VAX 11/780, SEL 86,
  2797.  
  2798. and Zilog Z80.  Calls to the standard I/O library will  work
  2799.  
  2800. on all of these machines.
  2801.  
  2802.  
  2803.   There are a number of supporting programs that go with  C.
  2804.  
  2805. lllliiiinnnntttt  checks  C programs for potential portability problems,
  2806.  
  2807. and detects errors such as  mismatched  argument  types  and
  2808.  
  2809. uninitialized variables.
  2810.  
  2811.  
  2812.   For larger programs (anything whose source is on more than
  2813.  
  2814. one  file) mmmmaaaakkkkeeee allows you to specify the dependencies among
  2815.  
  2816. the source files and the processing steps needed to  make  a
  2817.  
  2818. new  version;  it then checks the times that the pieces were
  2819.  
  2820. last changed and does the minimal amount of  recompiling  to
  2821.  
  2822. create a consistent updated version.
  2823.  
  2824.  
  2825.   The debugger aaaaddddbbbb is useful for digging  through  the  dead
  2826.  
  2827. bodies  of  C  programs,  but is rather hard to learn to use
  2828.  
  2829. effectively.  The most effective  debugging  tool  is  still
  2830.  
  2831. careful  thought,  coupled  with  judiciously  placed  print
  2832.  
  2833.  
  2834.  
  2835.                      November 16, 1985
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842. 44                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  2843.  
  2844.  
  2845. statements.
  2846.  
  2847.  
  2848.   The C compiler provides a limited instrumentation service,
  2849.  
  2850. so you can find out where programs spend their time and what
  2851.  
  2852. parts are worth optimizing.  Compile the routines  with  the
  2853.  
  2854. ----pppp  option;  after the test run, use pppprrrrooooffff to print an execu-
  2855.  
  2856. tion profile.  The command ttttiiiimmmmeeee  will  give  you  the  gross
  2857.  
  2858. run-time  statistics  of  a  program, but they are not super
  2859.  
  2860. accurate or reproducible.
  2861.  
  2862.  
  2863. _O_t_h_e_r _L_a_n_g_u_a_g_e_s
  2864.  
  2865.  
  2866.   If you _h_a_v_e to use Fortran, there are  two  possibilities.
  2867.  
  2868. You  might  consider Ratfor, which gives you the decent con-
  2869.  
  2870. trol structures and free-form input that characterize C, yet
  2871.  
  2872. lets you write code that is still portable to other environ-
  2873.  
  2874. ments.  Bear in mind that  UNIX  Fortran  tends  to  produce
  2875.  
  2876. large  and  relatively  slow-running programs.  Furthermore,
  2877.  
  2878. supporting software like aaaaddddbbbb, pppprrrrooooffff, etc., are all  virtually
  2879.  
  2880. useless  with Fortran programs.  There may also be a Fortran
  2881.  
  2882. 77 compiler on your system.  If so, this is a viable  alter-
  2883.  
  2884. native  to Ratfor, and has the non-trivial advantage that it
  2885.  
  2886. is compatible with C and related programs.  (The Ratfor pro-
  2887.  
  2888. cessor and C tools can be used with Fortran 77 too.)
  2889.  
  2890.  
  2891.   If your application requires you to translate  a  language
  2892.  
  2893. into a set of actions or another language, you are in effect
  2894.  
  2895. building a compiler, though probably a small one.   In  that
  2896.  
  2897. case,  you should be using the yyyyaaaacccccccc compiler-compiler, which
  2898.  
  2899.  
  2900.  
  2901.                      November 16, 1985
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        45
  2909.  
  2910.  
  2911. helps you develop  a  compiler  quickly.   The  lllleeeexxxx  lexical
  2912.  
  2913. analyzer  generator  does  the  same  job  for  the  simpler
  2914.  
  2915. languages that can be expressed as regular expressions.   It
  2916.  
  2917. can be used by itself, or as a front end to recognize inputs
  2918.  
  2919. for a yyyyaaaacccccccc-based program.  Both yyyyaaaacccccccc and  lllleeeexxxx  require  some
  2920.  
  2921. sophistication  to  use,  but the initial effort of learning
  2922.  
  2923. them can be repaid many times over in programs that are easy
  2924.  
  2925. to change later on.
  2926.  
  2927.  
  2928.   Most UNIX systems also  make  available  other  languages,
  2929.  
  2930. such  as  Algol  68,  APL,  Basic, Lisp, Pascal, and Snobol.
  2931.  
  2932. Whether these  are  useful  depends  largely  on  the  local
  2933.  
  2934. environment:  if  someone  cares  about the language and has
  2935.  
  2936. worked on it, it may be in good shape.  If not, the odds are
  2937.  
  2938. strong that it will be more trouble than it's worth.
  2939.  
  2940.  
  2941. _V.  _U_N_I_X _R_E_A_D_I_N_G _L_I_S_T
  2942.  
  2943.  
  2944. _G_e_n_e_r_a_l:
  2945.  
  2946.  
  2947. K. L. Thompson and D.  M.  Ritchie,  _T_h_e  _U_N_I_X  _P_r_o_g_r_a_m_m_e_r'_s
  2948.  
  2949. _M_a_n_u_a_l,  Bell  Laboratories,  1978.   Lists commands, system
  2950.  
  2951. routines and interfaces,  file  formats,  and  some  of  the
  2952.  
  2953. maintenance   procedures.   You  can't  live  without  this,
  2954.  
  2955. although you will probably only need to read section 1.
  2956.  
  2957.  
  2958. _D_o_c_u_m_e_n_t_s _f_o_r _U_s_e _w_i_t_h _t_h_e _U_N_I_X _T_i_m_e-_s_h_a_r_i_n_g _S_y_s_t_e_m.  Volume
  2959.  
  2960. 2  of the Programmer's Manual.  This contains more extensive
  2961.  
  2962. descriptions of major commands, and tutorials and  reference
  2963.  
  2964. manuals.   All  of the papers listed below are in it, as are
  2965.  
  2966.  
  2967.                      November 16, 1985
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974. 46                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  2975.  
  2976.  
  2977. descriptions of most of the programs mentioned above.
  2978.  
  2979.  
  2980. D. M. Ritchie and K. L. Thompson,  ``The  UNIX  Time-sharing
  2981.  
  2982. System,''  CACM,  July 1974.  An overview of the system, for
  2983.  
  2984. people interested in operating systems.   Worth  reading  by
  2985.  
  2986. anyone  who  programs.  Contains a remarkable number of one-
  2987.  
  2988. sentence observations on how to do things right.
  2989.  
  2990.  
  2991. The Bell System Technical Journal (BSTJ)  Special  Issue  on
  2992.  
  2993. UNIX,  July/August,  1978,  contains  many papers describing
  2994.  
  2995. recent developments, and some retrospective material.
  2996.  
  2997.  
  2998. The 2nd International  Conference  on  Software  Engineering
  2999.  
  3000. (October,  1976)  contains several papers describing the use
  3001.  
  3002. of the Programmer's Workbench (PWB) version of UNIX.
  3003.  
  3004.  
  3005. _D_o_c_u_m_e_n_t _P_r_e_p_a_r_a_t_i_o_n:
  3006.  
  3007.  
  3008. B. W. Kernighan, ``A Tutorial Introduction to the UNIX  Text
  3009.  
  3010. Editor''  and  ``Advanced  Editing  on  UNIX,'' Bell Labora-
  3011.  
  3012. tories, 1978.  Beginners need the introduction; the advanced
  3013.  
  3014. material will help you get the most out of the editor.
  3015.  
  3016.  
  3017. M. E. Lesk, ``Typing Documents on UNIX,'' Bell Laboratories,
  3018.  
  3019. 1978.   Describes  the ----mmmmssss macro package, which isolates the
  3020.  
  3021. novice from the vagaries of nnnnrrrrooooffffffff and ttttrrrrooooffffffff, and takes  care
  3022.  
  3023. of  most  formatting  situations.   If this specific package
  3024.  
  3025. isn't available on your system, something  similar  probably
  3026.  
  3027. is.  The most likely alternative is the PWB/UNIX macro pack-
  3028.  
  3029. age ----mmmmmmmm; see your local guru if you use PWB/UNIX.
  3030.  
  3031.  
  3032.  
  3033.                      November 16, 1985
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040. _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s                                        47
  3041.  
  3042.  
  3043. B. W. Kernighan and L. L. Cherry, ``A System for Typesetting
  3044.  
  3045. Mathematics,''  Bell  Laboratories  Computing  Science Tech.
  3046.  
  3047. Rep. 17.
  3048.  
  3049.  
  3050. M. E. Lesk, ``Tbl -  A  Program  to  Format  Tables,''  Bell
  3051.  
  3052. Laboratories CSTR 49, 1976.
  3053.  
  3054.  
  3055. J. F. Ossanna,  Jr.,  ``NROFF/TROFF  User's  Manual,''  Bell
  3056.  
  3057. Laboratories  CSTR  54,  1976.  ttttrrrrooooffffffff is the basic formatter
  3058.  
  3059. used  by  ----mmmmssss,  eeeeqqqqnnnn  and  ttttbbbbllll.   The  reference  manual   is
  3060.  
  3061. indispensable if you are going to write or maintain these or
  3062.  
  3063. similar programs.  But start with:
  3064.  
  3065.  
  3066. B. W. Kernighan, ``A TROFF  Tutorial,''  Bell  Laboratories,
  3067.  
  3068. 1976.  An attempt to unravel the intricacies of ttttrrrrooooffffffff.
  3069.  
  3070.  
  3071. _P_r_o_g_r_a_m_m_i_n_g:
  3072.  
  3073.  
  3074. B. W.  Kernighan  and  D.  M.  Ritchie,  _T_h_e  _C  _P_r_o_g_r_a_m_m_i_n_g
  3075.  
  3076. _L_a_n_g_u_a_g_e,  Prentice-Hall,  1978.  Contains a tutorial intro-
  3077.  
  3078. duction, complete discussions of all language features,  and
  3079.  
  3080. the reference manual.
  3081.  
  3082.  
  3083. B. W. Kernighan and D.  M.  Ritchie,  ``UNIX  Programming,''
  3084.  
  3085. Bell  Laboratories,  1978.   Describes how to interface with
  3086.  
  3087. the system from C programs: I/O calls, signals, processes.
  3088.  
  3089.  
  3090. S. R. Bourne, ``An Introduction to the  UNIX  Shell,''  Bell
  3091.  
  3092. Laboratories,  1978.   An  introduction and reference manual
  3093.  
  3094. for the Version 7 shell.  Mandatory reading if you intend to
  3095.  
  3096. make effective use of the programming power of this shell.
  3097.  
  3098.  
  3099.                      November 16, 1985
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106. 48                                        _U_N_I_X _f_o_r _B_e_g_i_n_n_e_r_s
  3107.  
  3108.  
  3109. S. C. Johnson, ``Yacc  -  Yet  Another  Compiler-Compiler,''
  3110.  
  3111. Bell Laboratories CSTR 32, 1978.
  3112.  
  3113.  
  3114. M. E. Lesk, ``Lex - A  Lexical  Analyzer  Generator,''  Bell
  3115.  
  3116. Laboratories CSTR 39, 1975.
  3117.  
  3118.  
  3119. S. C. Johnson, ``Lint, a C Program Checker,''  Bell  Labora-
  3120.  
  3121. tories CSTR 65, 1977.
  3122.  
  3123.  
  3124. S. I. Feldman, ``MAKE - A Program for  Maintaining  Computer
  3125.  
  3126. Programs,'' Bell Laboratories CSTR 57, 1977.
  3127.  
  3128.  
  3129. J. F. Maranzano and S. R. Bourne, ``A Tutorial  Introduction
  3130.  
  3131. to  ADB,'' Bell Laboratories CSTR 62, 1977.  An introduction
  3132.  
  3133. to a powerful but complex debugging tool.
  3134.  
  3135.  
  3136. S. I. Feldman and P. J. Weinberger, ``A Portable Fortran  77
  3137.  
  3138. Compiler,''  Bell Laboratories, 1978.  A full Fortran 77 for
  3139.  
  3140. UNIX systems.
  3141.  
  3142.  
  3143. _M_a_y _1_9_7_9
  3144.  
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.                      November 16, 1985
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.                    D O C U M E N T A T I O N   M E N U
  3172.                 
  3173. This menu allows you to access documents about some of the
  3174. features of UNIX and this system in general.  Many of the
  3175. documents are very long. WARNING - Once the listing starts,
  3176. it will not STOP until the whole document has been listed. 
  3177. It is recommended that you 'download' the document entitled
  3178. BEGIN and study it for a general background of the system.
  3179.  
  3180.      Size in bytes      Name of Document
  3181.      -------------- -----------------
  3182. A    55330              ADVICE.doc 
  3183. B    81391              BEGIN.doc 
  3184. C   143449              CSH.doc 
  3185. D    13599              SECURITY.doc 
  3186. E    76644              SETUP.doc 
  3187. F    73228              SHELL.doc 
  3188. G    83376              SYNOPSIS.doc 
  3189. H    68271              UNIX.doc 
  3190. I    33799              UUCP_NET.doc 
  3191. J    40932              U_IMPL.doc 
  3192. K    ?????              List of Usenet Groups
  3193. L    88534              List of ARPANET Groups
  3194. Command (ESC to exit)? 
  3195.  
  3196.  
  3197.      Another file downloaded from:                     NIRVANAnet(tm)
  3198.  
  3199.      & the Temple of the Screaming Electron              415-935-5845
  3200.      Just Say Yes                                        415-922-1613
  3201.      Rat Head                                            415-524-3649
  3202.      Cheez Whiz                                          408-363-9766
  3203.      Reality Check                                       415-474-2602
  3204.  
  3205.    Specializing in conversations, obscure information, high explosives,
  3206.        arcane knowledge, political extremism, diversive sexuality,
  3207.        insane speculation, and wild rumours. ALL-TEXT BBS SYSTEMS.
  3208.  
  3209.   Full access for first-time callers.  We don't want to know who you are,
  3210.    where you live, or what your phone number is. We are not Big Brother.
  3211.  
  3212.                          "Raw Data for Raw Nerves"
  3213.  
  3214.  
  3215.