

























































                                 - 1 -             February 21, 1980








                           INTRODUCTION TO UNIX






          uu         uu        nn       nn    iii     ttttttttt
          uu         uu        nnn      nn    iii        ttt
          uu         uu        nn n     nn    iii        ttt
          uu         uu        nn  n    nn    iii        ttt
          uu         uu        nn   n   nn    iii        ttt
          uu         uu        nn    n  nn    iii        ttt
          uuuuuuuuuuuuu        nn     nnn     iii        ttt


                             iiiiiiiiiiiiiiiii
                                iii iii iii
                                iii iii iii
                                iii iii iii
                                iii iii iii
                             iiiiiiiiiiiiiiiii


               (Unix Text Editor, Nroff, and Text Formatting)












                                                 Mildred M. Ware
                                                 September, 1978























   MP119                                        Introduction to UNIX


                       _T_A_B_L_E _O_F _C_O_N_T_E_N_T_S



                          _U_n_i_t _I_I_I


   A. Introduction to Unit III___________________________ 1
      Objectives for Unit III____________________________ 2

   B. Module I_____Text Editing

      Objectives_________________________________________ 3
      1. Unix Text Editor________________________________ 4
      2. Ed command______________________________________ 4
      3. Append command__________________________________ 5
      4. Write command___________________________________ 5
      5. Creating a file_________________________________ 6
      6. Quit command____________________________________ 7
      7. Error messages__________________________________ 7
      8. Displaying the file_____________________________ 8
      9. Modifying the file______________________________ 9
     10. Substitute command______________________________ 9
     11. Context searching_______________________________ 13
     12. Backward search ________________________________ 15
     13. Delete command__________________________________ 16
     14. Change command__________________________________ 16
     15. Insert command__________________________________ 17
         Advanced Features:
     16. Append command__________________________________ 19
     17. Write command___________________________________ 19
     18. Move command____________________________________ 20
     19. Edit command____________________________________ 21
     20. File command____________________________________ 23
     21. Read command____________________________________ 23
     22. Global command__________________________________ 26
     23. "V" command_____________________________________ 27
     24. Special characters______________________________ 27
         a. The Circumflex________________________________28
         b. The Dollar Sign_______________________________28
         c. The I Don't Care Character____________________29
         d. The Repetition Character______________________30
         e. Character Classes_____________________________30
         f. The Line Repeat Character_____________________31
         g. The Backslash Character_______________________32
     25. Summary of commands_____________________________ 35
     26. Module I Test___________________________________ 36
     27. Answers to Module I test________________________ 37

   C. Module II----NROFF
      Objectives_________________________________________ 40
      Introduction to Nroff______________________________ 41

                                 - i -






   MP119                                        Introduction to UNIX

      1. Nroff commands__________________________________ 42
      2. Page control formatting_________________________ 43
      3. Text placement control__________________________ 46
      4. Adjusting output lines__________________________ 48
      5. Vertical spacing________________________________ 49
      6. Setting line lengths____________________________ 53
      7. Indenting_______________________________________ 54
      8. Macros__________________________________________ 55
      9. Arguments_______________________________________ 56
     10. Character strings_______________________________ 58
     11. Underlining_____________________________________ 61
     12. Generating titles_______________________________ 62
     13. Numbering pages_________________________________ 63
     14. Displaying the current date_____________________ 63
     15. Character translation___________________________ 64
     16. Defining tabs___________________________________ 65
     17. Summary of commands_____________________________ 68
     18. Module II Test__________________________________ 71
     19. Answers to Module II test_______________________ 73

   D. Module III---- Additional formatting techniques
      Objectives_________________________________________ 75
      Introduction to "NM MACROS"________________________ 76
      1. Headers_________________________________________ 76
      2. Footers_________________________________________ 77
      3. Generating classifications______________________ 78
      4. Underlining_____________________________________ 79
      5. Paragraph formation_____________________________ 80
      6. Paragraph headings______________________________ 81
      7. Outline style paragraph headings________________ 84
      8. Table of contents_______________________________ 85
      9. Forming outlines________________________________ 85
     10. Bullet marked items_____________________________ 90
     11. Word hyphenation________________________________ 90
     12. Annotating files________________________________ 92
     13. Module III Test_________________________________ 93
     14. Answers to Module III test______________________ 95
     15. Summary of "NM MACROS"__________________________ 97
     16. Unit III Proficiency Test_______________________ 98














                                - ii -







   MP119                                        Introduction to UNIX


                        _U_N_I_T _I_I_I -- _T_E_X_T _E_D_I_T_I_N_G


        This Unit  discusses  text  editing,  text  formatting,  and
   nroff.

        In module 1, you will learn to edit your  files  by  adding,
   changing, inserting, and deleting information.

        In module 2, you will learn to format your files by  utiliz-
   ing  nroff,  a  text  processor. Nroff also interprets and places
   your formatted file in readable form.  Controlling  output,  set-
   ting line lengths, vertical spacing, indenting, underlining, mac-
   ros, character strings, and line numbering are among  the  topics
   to be discussed.

        In module 3, you will  learn   additional  formatting  tech-
   niques.   Topics  will include forming headers, trailers, indent-
   ing, underlining, paragraphing, etc.

































                                 - 1 -







   MP119                                        Introduction to UNIX


                       _O_B_J_E_C_T_I_V_E_S _F_O_R _U_N_I_T _I_I_I

   When you complete this unit, you will be able to:



    1.  Use the command to gain access to the  UNIX Text editor.

    2.  Modify your files by using the UNIX Text Editor commands.

    3.  Use the command to terminate use of the UNIX Text Editor.

    4.  Use the command to gain access to nroff.

    5.  Use the nroff commands to format your files.

    6.  Use the "nm macros" to enhance text formatting.



































                                 - 2 -







   MP119                                        Introduction to UNIX


                    _M_O_D_U_L_E _I -- _T_e_x_t _E_d_i_t_i_n_g


        This module covers UNIT III objectives 1, 2, and, 3.

        _O_b_j_e_c_t_i_v_e_s

   After completion of this module, you will be able to:



    1.  Use the command to gain access to the UNIX Text Editor.

    2.  Append text to a file.

    3.  Insert text into a file.

    4.  Reposition text within a file.

    5.  Modify text within a file.

    6.  Delete text from a file.

    7.  Create sub-files.

    8.  Edit more than one file simultaneously.

    9.  Display a line/lines of the edited file.

   10.  Use the command to terminate use of the editor.






















                                 - 3 -
   Unit III                                                Module II






   MP119                                        Introduction to UNIX


                        _T_h_e _U_n_i_x _T_e_x_t _E_d_i_t_o_r


        I know there have been times when you must have  wished  you
   had  placed  another  piece of information into the file you just
   created, or maybe you would just like to change it around a  lit-
   tle,  or  maybe  even delete some of it.  Prior to this unit, you
   were sort of handicapped and probably a little frustrated because
   you  couldn't  do  any  of  these things. This module is going to
   teach you to do all this and more, so let's begin.

        _E_D _C_o_m_m_a_n_d


        The Unix Text Editor allows you to modify your text files by
   using special commands; that is, the commands employed only while
   using the editor. To obtain use of the editor, you must issue the
   following command:

                       % ed <filename>

   where "ed" gives you access to the editor, and "filename" is  the
   name  of the file to be modified.  The system reads the specified
   file into a buffer.  Think of the buffer as a work  area  or  the
   first  draft  of  a  report,  where you are going to make all the
   necessary changes before typing the final draft.  While  you  are
   using the editor, you may change and rechange the file as much as
   you like. When you have the file as you want  it,  then  you  are
   going  to direct the system to write or place the contents of the
   buffer (modified version of the file)  back  into  the  specified
   file.

        The system lets you know when you have gained access to  the
   editor  by  displaying  the  number  of  characters read into the
   buffer. (The number of characters contained  in  the  file  being
   read into the buffer).

                       Example: % ed junk

                       Response: 685


        This is the only information displayed.  To get  the  system
   to perform any other action such as displaying the file, requires
   using one of the editor commands discussed in the following  sec-
   tions.





                                 - 4 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

        _T_h_e _A_p_p_e_n_d _C_o_m_m_a_n_d


        This command allows you to append (or add) text lines to the
   buffer.

             Example:  Assume that the file being edited contains:

                       Now is the time
                       for all good men
                       to come to the aid
                       of their country.

             And you type:
                       a
                       Rise up, rise up young men!
                       Uncle Sam needs you now
                       .

   Where "a" is the append command, and the "." is used to tell  the
   editor that you have no more text to add to the buffer.

                       The buffer now contains:

                       Now is the time
                       for all good men
                       to come to the aid
                       of their country.
                       Rise up, rise up young men!
                       Uncle Sam needs you now.

   Notes: (1) To add  more  text  to  the  buffer,  just  issue  the
              "append" command again.
          (2) Everything you type between the "a" and the  "."  will
              be  added  to  the  contents of the buffer (other com-
              mands, errors, everything), so don't  forget  to  type
              the "." when you have finished entering the text.
          (3) The "." must be the only character on the line.   That
              is, you should type:

                         . <return>

        _T_h_e _W_r_i_t_e _C_o_m_m_a_n_d


        The "write" command is used to write  the  contents  of  the
   buffer into the file being edited (destroying any previous infor-
   mation in the file). No modifications are actually  made  to  the
   file  until the "write" command is issued.  Prior to issuing this
   command, the modifications are made to the copy of the file which
   is contained in the buffer.  The form of the command is:

                                 - 5 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

                               w

   The system responds by displaying the number of characters in the
   file.  This  count  includes spaces and the end of line character
   generated when the return key is depressed.

        Let's take a look at the commands you've learned so  far  in
   this module.

                            % ed junk
                            a
                            <text>
                            .
                            w

   Notes: (1) The "write" command doesn't destroy  the  contents  of
              the  buffer; thus, you may continue to modify the file
              after issuing the "write" command.
          (2) You should issue the "write"  command  following  each
              change made to the file, rather than waiting until you
              have made all  the  intended  changes.  This  is  some
              insurance  against  losing  all copies of the modified
              file if the system goes down suddenly.

        _C_r_e_a_t_i_n_g _a _F_i_l_e


        The editor can also be used to create a file.  To  do  this,
   the following sequence of commands are issued::

                            % ed
                            a
                            <text>
                            .
                            w junk

   You will notice that the filename has been specified in  the  "w"
   command  instead  of  in  the "ed" command. Thus, the file "junk"
   will be created when the "w" command is executed.

        Okay, what do you think will be the result of the  following
   commands?  Put your answer in the space provided.

                            % ed junk
                            a
                            <text>
                            .
                            w temp




                                 - 6 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   Answer: If your answer is: The file "temp" will be  created  con-
   taining  the concatenation of the file "junk" with "<text>"; very
   good. Note that the file "junk" remains unchanged.

        _T_h_e _Q_u_i_t _C_o_m_m_a_n_d


        To terminate your session in the editor,  issue  the  "quit"
   command by typing:
                               q

   The system will respond by displaying the "%".  You are  now  out
   of the editor.

   Note: Before issuing this command, be sure to issue  the  "write"
         command.   The  "quit" command erases the buffer containing
         the modified copy of your file. If you should type "q" when
         you  have  not  written the file, the system will display a
         "?" to remind you.

        _E_r_r_o_r _M_e_s_s_a_g_e_s


        If you make an error in typing the editor commands, the sys-
   tem will let you know displaying:

                               ?

   This really lets you know where you goofed doesn't it? Well don't
   worry,  with  a little practice you won't have any trouble deter-
   mining where you went wrong. To correct, just retype the command.

        _E_x_e_r_c_i_s_e

   Okay, you've learned enough commands to have your  first  editing
   session; so get to it.

    1.  Using the UNIX Text Editor, create a file called "junk."

    2.  Leave the editor and display the file.

    3.  Using the editor, append  a  couple  of  lines  of  text  to
        "junk." (This text can be anything you want to add.)

    4.  Repeat #2







                                 - 7 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

                        _D_i_s_p_l_a_y_i_n_g _t_h_e _f_i_l_e


        _P_r_i_n_t_i_n_g _t_h_e _C_o_n_t_e_n_t_s _o_f _t_h_e _B_u_f_f_e_r


        To display the contents of the buffer (or parts  of  it)  on
   the terminal, use the "print" command, "p."

        In issuing the "print" command you specify the  lines  where
   you want printing to begin and end, separated by a comma and fol-
   lowed by a "p," as follows:

                            1,5p

   This particular command will display the first  5  lines  of  the
   buffer.   Suppose  you  want  to  display  the entire file in the
   buffer.  How can you do this?  Well, you are  probably  thinking,
   that's  easy,  just  use the same form as above, only specify the
   last line in the file instead of the "5th." This  is  fine,  pro-
   vided  you  know  the number of lines in the buffer. However, you
   would be in trouble if you didn't. Well,  the  designers  of  the
   Unix Text Editor took this into consideration and provided a sym-
   bol which can be used to point to the last line  in  the  buffer,
   the dollar sign ($).  To use it, enter the following command:

                            1,$p

   which will display all lines in the buffer.

        _D_i_s_p_l_a_y_i_n_g _a _s_i_n_g_l_e _l_i_n_e


        Any single line in the  buffer  can  also  be  displayed  by
   specifying the line number followed by a "p"; thus,

                            2p

   will display the 2nd line of the buffer.  What will be  displayed
   by the command "$p"?


   You're correct if you said the last line in the buffer.

        UNIX makes it even easier for you. You  can  get  away  with
   just  typing  the  line number -- omitting the "p."  So you could
   type just the

                            2 or $

   in the two previous commands.

                                 - 8 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        That isn't all, look at what else you can do.   Suppose  you
   want  to  display the last two lines of the buffer, and you don't
   know the number of lines contained in  the  buffer.   This  could
   pose  quite  a problem. However, Unix makes it quite simple. Just
   enter:

                            $-1,$p

   and the problem is solved.

   Which lines will be displayed when you issue the  following  com-
   mand?

                            $-5,$-2p

   Answer:  The 5th line from the last through the 2nd line from the
   last -- thus, 4 lines.

   Note: The beginning line specified must be less than  the  ending
         line specified; eg., "3,1p" wouldn't work.

        _T_h_e _C_u_r_r_e_n_t _L_i_n_e


        The current line is the last line you displayed, changed, or
   did anything else with. The editor maintains a record of the line
   you most recently did something  to,  so  that  it  can  be  used
   instead  of an explicit number. This feature, similar to the "$,"
   is quite beneficial in forming commands when you don't  know  the
   line  number.  The  symbol  which denotes the current line is the
   period (.), referred to as "dot." Let's look at a few examples to
   determine just how it may be used.

        Suppose you typed "1,3p" and  then  you  typed  ".,$p."  All
   lines  from  the  current  line (line 3) to the end of the buffer
   will be displayed.  Why is line 3 the current line?  Because that
   was the last line displayed or referenced.

        Dot is most useful when used in combinations like  the  fol-
   lowing:

                            +1 or .+1p

   which will display the line following the current line.

   Note: The return key does the same thing., Now, you  figure  this
         one out.




                                 - 9 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

        -1 or .-1p ---- will display which line? Put your answer  in
   the space provided.


   Answer: The line before the current  line.  If  that's  what  you
   answered, you're getting the hang of it.

   The command -3, .-1p will display the previous three lines.

        Don't forget that all of these commands change the value  of
   dot.  To determine which line is the current line, simply type

                               .=


        This causes Unix to display the number of the current  line.
   For example, you type "1,5p," then ".="; the system will display:

                               5

   Note: "p" can be preceded by 0, 1, or  2  line  numbers.   If  no
         number  is  specified  (just  "p"),  the  current  line  is
         displayed;  if  1  number  is  specified,  that   line   is
         displayed; and if 2 numbers are specified, all lines within
         that range are displayed.

        _E_x_e_r_c_i_s_e


        Experiment with the "p" command  by  typing  all  the  above
   comands  on  the file "junk", you created earlier.  (The commands
   are "p", "dot", dollar sign ($),  and  the  "minus"  and  "equal"
   signs.)

                        _M_o_d_i_f_y_i_n_g _t_h_e _f_i_l_e


        Since you are now proficient in displaying your files, let's
   move  on to bigger and better things.  You are now going to learn
   how to change the information in your files.

        _T_h_e _S_u_b_s_t_i_t_u_t_e _c_o_m_m_a_n_d


        This command is perhaps the most useful and versatile of all
   the commands; it can be used to replace, insert, and delete char-
   acters from the buffer.  You will now be able  to  correct  those
   typing errors you've been making.  The form of the command is:

                     s/old string/new string/


                                - 10 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   where "old string" (any characters placed between the first  pair
   of  slashes)  is  replaced by "new string" (any characters placed
   between the second pair of slashes).

   Example:  Suppose you typed line 1 of our  previous  sample  file
   as:
                        "Now is the tiem"

   where "me" of time is transposed.  You can use the following com-
   mand to fix it up:
                        s/tiem/time/

   This will substitute  the  first  occurrence  of  "tiem"  of  the
   current  line  with  "time".   We are assuming that line 1 is the
   current line. If it isn't, you would use the command:

                        1s/tiem/time/

        What does this do? It makes line 1 the  current  line.   The
   "1"  is  a  form  of  the "p" command isn't it? And the last line
   specified in the "p" command becomes the current line doesn't it?
   Therefore, the "1" in this command makes line 1 the current line.
   This form of the substitute command allows you to  be  selective,
   that is, you can specify which line you want to modify.

        Several lines may be modified by using the  following  form:
   "starting-line,ending line s/old string/new string/."

             Example:   1,$s/programer/programmer/

   will correct the first occurrence of "programer" on each line  of
   text.

   Notes: (1)  Dot is set to the last line changed.

          (2)  The rules  for forming line numbers in the  "s"  com-
               mand  and all subsequent commands are the same as for
               the "p" command.

          (3)  "Old string" doesn't have to be an entire word - only
               a  unique  string  of characters. For instance, if no
               other word ended in "mer," then  "old  string"  could
               have  been "mer" instead of "programer" in the previ-
               ous example.

          (4)  If no substitution took place, dot is not changed and






                                - 11 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

               a "?" is displayed.

          (5)  Unix doesn't require that a "/" be  used  to  delimit
               "old  string"  and  "new string." Any character other
               than a blank or a character in one of the strings may
               be used.

        _O_t_h_e_r _E_x_a_m_p_l_e_s



    1.  You can insert words.  Suppose  you  typed  "now  the  time"
        instead of "now is the time." Then you could issue

                            s/the/is the/p

        In this case "p" is used to display the corrected line.

    2.  You can delete characters/words from a  line.   Suppose  you
        typed:

                       "Now is the is the time."

        You could correct this by using:

                            s/is the//p

        which means to replace the first occurrence of "is the" with
        nothing.

   Note: There is no space between the second pair of slashes. Ques-
         tion:  what  would  be  the  result  if you left two spaces
         between the slashes?  The first "is the" would be  replaced
         by two spaces.

        _E_x_e_r_c_i_s_e



    1.  Create the following file using "ed."

               Now is the time for all good men
               to come to the aid of their
               their country now is the time

    2.  Modify such that it reads:

               Don't delay, now is the time for
               all good men and women to come to
               the assistance of their fellowman.


                                - 12 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

    3.  Verify each line as it is  corrected.  Then,  following  the
        last correction, display the entire modified file.

        Now, you're really beginig to see how UNIX can work for you.
   Let's move on.

        _C_o_n_t_e_x_t _S_e_a_r_c_h_i_n_g


        Another very important feature of "ed" is context searching.
   Context  searching  is  simply  another  method of specifying the
   desired line without using a number.  The form of the command is:

                  /characters you want to find/

        Suppose you want to change "their" to "the" of your previous
   file.   You're  probably  thinking,  "No  big  deal,  just  'type
   3s/their/the/.'" Well, this would be fine for a small  file  such
   as  we  have, but what if the file contains several hundred lines
   of text, and you've been adding, deleting, rearranging lines, and
   so  on.  You  would no longer know which line you were on. Conse-
   quently, you would not know what number to specify.  However, you
   could use this command:

                            /their/

   which would locate the next occurrence of  "their,"  display  the
   line  for  verification,  and set dot to that line.  Now, all you
   have to do is to issue the "s" command.  Both  of  these  can  be
   issued simultaneously by:

                     /their/s/their/the/p

   For example, this would yield:

                  to come to the aid of the country

   Notes: (1)  The system performs a  "wrap  around"  search  --  it
               begins  with  current  line  and  searches  until  it
               encounters either the characters searched for or  the
               current line again.

          (2)  If  the  character  string  isn't  found,  a  "?"  is
               displayed.








                                - 13 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _O_t_h_e_r _E_x_a_m_p_l_e_s



    1.  Suppose you don't want the first occurrence of  a  character
        string.   Well,  there  is  a simple remedy to this problem.
        Just type:

                              //

        and  the  system  will  continue  its  search  for   another
        occurrence of the most recently searched for string of char-
        acters.

        Note: This notation can also be used in conjunction with the
        "s" command as follows:

                         /their/s//the/p

        Notice, there is  no  need  to  specify  the  "searched  for
        string" again.

    2.  A context search expression is the same as  a  line  number.
        Therefore, it can be used any place a line number is used.

            a.  Suppose the buffer contained:

                          Now is the time for all
                          good men to come to the aid
                          of their country.

                How can the 2nd line be displayed? Write your answer
                below.



                Answer: By using either  of  the  following  expres-
                sions:

                          _C_o_n_t_e_x_t _S_e_a_r_c_h         '_P' _C_o_m_m_a_n_d

                               /now/+1                 1+1p
                               /men/                   2p
                               /their/-1               $-1p

                Well, why not use the "p" command as it  appears  to
                be easier to form?  The "p" command is the preferred
                form if you know the line numbers. However, this  is
                highly unlikely if you're using a large file.


                                - 14 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

            b.  To change "good" to "bad", you could use:

                               /now/+1s/good/bad/
                          or
                               /good/s/good/bad/
                          or
                               /their/-1s/good/bad/
            c.  To print all three lines, you could use:

                               /now/,/now/+2p
                          or
                               /now/,/their/p

                Notice that the following form is adhered to:

                               starting-line, ending-linep

        _B_a_c_k_w_a_r_d _S_e_a_r_c_h


        To perform a backward context search, use:

                  ?characters you want to find?
        instead of
                  /characters you want to find/

   This form would be used if it is suspected  that  the  characters
   searched  for  can be located faster doing a backward search than
   doing a wrap around search.  This  is  an  extremely  significant
   point when performing several searches on a large file.

   Note: To locate another occurrence of the characters,  use  "??".
         O.K.,  let's practice what was just covered. Do the follow-
         ing exercises.

        _E_x_e_r_c_i_s_e


        Use the original file created in the last  section.   Modify
   the file as indicated. However, use context search expressions to
   replace the line numbers in the "s" and "p" commands.

        If you managed without difficulty, continue on to  the  next
   section.  Otherwise, repeat the exercise.








                                - 15 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _T_h_e _D_e_l_e_t_e _C_o_m_m_a_n_d


        The delete command is used to remove a line/lines  from  the
   buffer.   The form of this command is very similar to the form of
   the "p" command:

                  starting-line,ending-line d
   Thus:
                               2,4d

   will delete lines 2 thru 4.  Dot is set to the line following the
   last  deleted  line, unless that line happens to be the last line
   in the buffer.  In that case, dot is set to the last line.

        You may also delete a single line.  Suppose you have 6 lines
   in the buffer, and you want to delete the 3rd line.  What command
   would you issue and what is the value of dot after the  deletion?
   Write your answer below.


        If your answer is: "3d" and "3," very good! You  didn't  say
   dot would be set to 4 did you? Remember line 4 is now line 3.

        _T_h_e _C_h_a_n_g_e _C_o_m_m_a_n_d


        This command is used to change or replace one or more  lines
   in the buffer.  The form to use is:

                  starting-line,ending-line c
                  <type the lines of text>
                  . (period)

        The form of this command is very  similar  to  the  "append"
   command isn't it?

   Example: Suppose the buffer contains:

                  Now is the time
                  for all good men
                  to come to the aid of their country

   and you typed:

                  1,2c
                  Now is the time, now is the time!
                  for all
                  to come to the aid of their country.  .


                                - 16 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   In this example, the system would delete the first set  of  lines
   and  replace them with what you typed betweem the "c" command and
   the ".": this does not have to be done on a one  for  one  basis.
   Several lines may be used to replace a single line or vice versa.

   Note: A single line number or no line number  may  be  specified,
         for example:

                           3c
                           <text>
                           .

         will replace the 3rd line with "text." Now, how  about  you
         trying  one. The following command will replace which line?
         Answer in the space provided.

                           c
                           <text>
                           .


         Answer: If you said dot or the current line, you are really
         on your toes.

        _T_h_e _I_n_s_e_r_t _C_o_m_m_a_n_d


        You learned earlier how to insert characters and words.  You
   can also insert a line or a group of lines.  The form of the com-
   mand is:

                       line-numberi
                       <text you type>
                       . (period)

   The system inserts whatever you type between the "i" and the  "."
   just before the specified line.

   Example: We'll refer to the  preceding  example  and  instead  of
   using the change command, use the insert command.  Let's see what
   happens. Recall that before we modified it our expression was:

                  Now is the time for
                  all good men to come
                  to the aid of their country
   Let's issue the "insert" command as follows:

                  2i
                  Now is the time, now is the time!
                  for all
                  .

                                - 17 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   The buffer will now contain:

                  Now is the time
                  Now is the time, now is the time!
                  for all
                  for all good men
                  to come to the aid of their country.

   Suppose you didn't know the line number, how could the  above  be
   accomplished?

   Solution: Use a context search expression  to  replace  the  line
   number.

             Example:  /for/i
                       Now is the time, now is the time!
                       for all
                       .(period)

   If you had the above solution, move to the head of the  class  --
   you're doing fine.

   Note: If a line-number isn't specified, the text is placed before
         the current line.

   Ready to try a couple of examples at the terminal? Do the follow-
   ing exercises.

        _E_x_e_r_c_i_s_e



    1.  Modify the following file:

                       Now is the time
                       for all good men
                       to come to the aid of their country!

        Use the change and insert commands such that it reads:

                  Attention! Attention all!
                  Now is the time
                  Not tomorrow
                  But today!
                  Come to the aid of your country!

    2.  Display line two. Replace it with:

                       Your country needs you.



                                - 18 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


                       _A_D_V_A_N_C_E_D _F_E_A_T_U_R_E_S


        _T_h_e _A_p_p_e_n_d _c_o_m_m_a_n_d


        In a previous section, you  used  the  "append"  command  to
   create  a  file and to add information to the end of a file.  The
   append command may also be used to add text or information at any
   point within a file by specifying a line number.

             Example:       3a
                            <text>
                            .

   Will add "text" to the buffer just  after  the  3rd  line.   This
   aspect  of  the  append command is almost identical to the insert
   command except "insert" places the text before the specified line
   and append places the text after the specified line.  Okay, let's
   look at another

             Example        Oa
                            <text>
                            .

   See, you can even specify 0 as a line number.  Where do you think
   the text will be placed?  Answer below:



   Right you are, the text is placed before the text already in  the
   buffer.   Can  the  insert command be used to do exactly the same
   thing?

   Yes, of course, just specify a line number of 1 instead of 0.

        _T_h_e _W_r_i_t_e _C_o_m_m_m_a_n_d


        A line number can also be used in the "write" command.  This
   lets  you  write  exactly the lines you want, not necessarily the
   entire buffer.  You can now extract certain lines from  one  file
   and create another file consisting of the extracted lines.

        But why would anyone want to do this?  Okay, let's  consider
   the following problem. You have a file consisting of several hun-
   dred lines of text. However, you are only interested in lines 250
   - 300.  Why bother wasting time printing the entire file and then
   scanning the printout until you locate the portion that interests
   you?   Instead,  you could just use the following form of the "w"

                                - 19 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   command and obtain a copy of only the portion you want:

             starting-line,ending-linew <filename>

                  Example:  250,300w junk

   "Junk" would now contain the 51 lines of text  that  were  origi-
   nally lines 250 - 300 of the file in the buffer.

   Note: A single line may also be extracted by specifying just that
         line.

        _T_h_e _M_o_v_e _c_o_m_m_a_n_d


        The "move" command lets you move a group of lines  from  one
   place  to  another  in the buffer.  Refer to the modified file in
   the preceding exercise.  Suppose you want  the  first  two  lines
   placed  at  the  end  of the file.  This can be done by using the
   following commands:

                  $a
                  come to the aid of your country
                  attention! attention all!
                  your country needs you.
                  .
                  1,2d

   However, the same thing can be accomplished with a single command
   --- the "move" command.  It has the form:

             starting-line,ending-line m'after this line'

                       Example:    1,2m$

   This does the same thing as if you had used both the "a" and  "d"
   commands.   It  is much easier though, isn't it? You will  notice
   that a third line number must be specified --  this  denotes  the
   place where the moved stuff is to be put.


   Note: Dot is set to the line number of the last line moved.  That
         is,  dot  is  set  to  the number assigned to the last line
         moved. In the above example, dot would be set to $.








                                - 20 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _E_x_e_r_c_i_s_e


        Use the modified file in the previous  exercise.   Move  the
   first  two  lines  to  the end of the buffer.  Use context search
   expressions instead of line numbers. Write the proper command  to
   do these things in the space below:

        Look at the answer below only if you find you  can't  do  it
   yourself; then try it on the terminal.


             Answer: /attention/,/country/m/country!/


   Note: You could have used any string of characters on lines 1, 2,
         and  5  to  form your context search expression, as long as
         not more than one of the three expressions appeared on  the
         same  line.  Why? Because the system begins its search with
         the  line  containing  the  previous  search   expresssion.
         Therefore,  if  more than one of the expressions appears on
         the same line, it will locate that line.

        _T_h_e _E_d_i_t _C_o_m_m_a_n_d


        "Edit" is becoming quite sophisticated now, isn't it?  Well,
   hang  tight  'cause you ain't seen nothing yet. You can even edit
   or work on several files in the same editing session  by  use  of
   the  "edit" command. This command is somewhat similar to the "ed"
   command in that it places a specified file into the buffer.  Sup-
   pose  you have two files "temp" and "junk," that need to be modi-
   fied. You can edit them both by:

                  % ed temp

                  <issue commands to modify temp>

                  w temp

                  e junk


        The "e" command will place the file "junk" into  the  buffer
   and display the number of characters contained in "junk." You can
   then issue the necessary commands to modify  "junk."  Before  the
   session  ends,  if  you  want to do something else to "temp" just
   type "e temp."

   Note: Before issuing the "e" command, be sure to  issue  the  "w"

                                - 21 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

         command  for  the file currently contained in the buffer as
         "e" destroys anything already in the buffer.

   Examples:

   (1) Let's refer to the previous problem of extracting  a  portion
       of  a  file.  In  that  problem, you couldn't even verify the
       newly created file "junk," because the file was  not  in  the
       buffer.  By  using the "e" command you can now display/modify
       the file "junk."

                 Example:   % ed temp
                           250,300w junk
                           e junk

       The above commands create junk and place  its  contents  into
       the buffer.

       Note: Before a file can be modified,it must be in the buffer.

   (2) A file can also be created  while  editing  another  file  by
       using the "append" command.

                    Example:   %ed temp
                                 |
                                 |
                                 |

                                 w temp

                                 e junk

                                 a
                                 <text>

                                 .

                                 w

       In this case  we've  appended  "<text>"  under  the  filename
       "junk."

   Note: "w" not accompanied by a filename  implies  the  file  con-
         tained  in  the  buffer. Also, in this situation the editor
         will disaplay a "?" following the "e" command.  Ignore  the
         "?" and continue with the "a" command.






                                - 22 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

        _T_h_e _F_i_l_e _C_o_m_m_a_n_d


        If you are editing several  files  simultaneously,  you  may
   forget  which file is currently occupying the buffer.  The "file"
   command is provided to keep track of  the  file  currently  being
   edited. Just type:

                               f

   and the editor will display the name of the file currently in the
   buffer.

        _T_h_e _R_e_a_d _C_o_m_m_a_n_d


        The "read" command is also used to place  a  file  into  the
   buffer.  However, unlike the "e" command, it does not destroy the
   text already there.  Suppose you  want  to  concatenate  the  two
   files "junk" and "temp," before editing. You can by typing:

                       % ed temp

                         r junk

   This causes "junk" to be appended to  the  end  of  the  copy  of
   "temp" in the buffer.

        _L_i_n_e _n_u_m_b_e_r_s _w_i_t_h _R_e_a_d


        You can use line numbers with the "read" command to  specify
   where  the file is to be placed in the buffer rather than have it
   placed at the end of the text already there.

   Examples:

   (1) Or junk: would place the contents of "junk" before  the  text
       already in the buffer. Remember "o" is zero.

   (2) 2r junk: would insert the contents of "junk" between the  2nd
       and the 3rd lines of text contained in the buffer.

   (3) Suppose the buffer contains:
                 now is the time
                 for all good men
                 to come to the aid
                 of their country

       and you type:


                                - 23 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

                       3r

       The buffer would now contain:

                 now is the time
                 for all good men
                 to come to the aid
                 now is the time
                 for all good men
                 to come to the aid
                 of their country
                 of their country

        Observe that if a filename isn't specified, the editor  uses
   the  file  in the buffer.  In this example, a copy of the current
   file is inserted between the 3rd and the 4th lines of text in the
   buffer.

        Now, do the following exercises to try some of the new stuff
   you've learned.
































                                - 24 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _E_x_e_r_c_i_s_e_s



    1.  Create the following file in the editor, call it "junk."

                  now is the time
                  for all good men
                  to come to the aid
                  of their fellowman

    2.  Remain in the editor and create the following file; call  it
        "junk2".

                  Attention! Attention All!
                  now is the time
                  not tomorrow,
                  but today!
                  come to the aid of your country.

    3.  Create a file called "junk3" which contains lines 2 -  4  of
        "junk2".  Display "junk3".

    4.  Combine "junk" and "junk3" by placing "junk" before "junk3".
        Place the combined file in "junk4". Display "junk4".

    5.  Combine "junk" and "junk2" by placing "junk" after  the  3rd
        line  of  "junk2".   Place  the  combined  file  in "junk5",
        display "junk5".

    6.  Leave the editor, display all 5 files, then delete them.


   You're beginning to see the power of UNIX. But, keep  on,  as  we
   have more good things in store for you.
















                                - 25 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _T_h_e _G_l_o_b_a_l _C_o_m_m_a_n_d


        When you learned the  "s"  (substitute)  command,  you  were
   somewhat  disadvantaged  due  to  the  fact  that  only the first
   occurrence of a specified string of characters on each  line  was
   modified.  Now, by using the global or "g" command in conjunction
   with the "s" command each occurrence of a specified string can be
   modified.

                Example:   s/programer/programmer/

   will modify the first occurrence of "programer"  on  the  current
   line.  On the other hand:

                     s/programer/programmer/g

   will modify each occurrence of "programer" on the current line.

        To modify all occurrences of a specified string  within  the
   entire file, you must reference each line, as follows:

                   1,$s/programer/programmer/g

   The "g" command can be used with the context search command also.

        _E_x_a_m_p_l_e_s

   1.   g/their/p

        This command will locate all lines  containing  "their"  and
        will display the last line found. The following command

                             /their/p

        will locate and display only the next occurrence of "their."

        Note: Use of "g" obviates the need to repeatedly  type  "//"
              in  order  to  locate  all  occurrences  of  a certain
              string. To display each line  containing  the  string,
              append a "p" to the end of the command.


   2.   Let's combine context searching with the "s"  and  "g"  com-
        mands.  It's done as follows:

                       g/programer/s//progammer/g

        Here is a question to check your understanding of  what  was
        just covered.

                                - 26 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

        How  can  the  above  command  be  modified  such  that  the
        corrected lines are displayed? Answer in the space provided.



        That's correct, just place a "p" after the last "g."


   Note: As you have probably observed, the "1,$" preceding the  "s"
         command,  and  the context search command preceding the "s"
         command seem to accomplish the same result.  Your  observa-
         tion  is  correct. However, if you append a "p" to the com-
         mands, the results would now differ. For instance,

                    1,$s/programer/programmer/gp

         will display only the last modified line, whereas,

                    g/programer/s//programmer/gp

         will display each modified line.

        _T_h_e _v _c_o_m_m_a_n_d


        This command is the same as the "g" command except that  the
   commands  following  the "v" are executed on every line that does
   not contain the specified characters. This command:

                              v//d

   will delete all lines that do not contain a blank. Got  that?  On
   the other hand,

                           v/as/s/o/a/g

   will substitute an "o" for an "a" on all lines except those  con-
   taining "as."

        _S_p_e_c_i_a_l _C_h_a_r_a_c_t_e_r_s


        Unix provides several special characters which are  used  to
   simplify  the forming of character string expressions used in the
   "g," "v," "s," and context search commands. These characters are:

                             ^ . $ [] * & \

   and have special meanings to the editor.



                                - 27 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

        Let's get on with it  and  see  how  sophisticated  you  can
   become in forming character string expressions.

        _T_h_e _C_i_r_c_u_m_f_l_e_x


        The circumflex (^) signifies the beginning  of  a  line.  By
   using  this symbol, you can determine whether a string of charac-
   ters is at the beginning of a line. The following command:

                                 /^the/

   will locate the first line, from the current line, beginning with
   "the". What will the following locate? Answer in the space below.

                                g/^the/



   Answer: All lines beginning with "the". If  that's  your  answer,
   very  good. Now form the command to change all lines beginning in
   "the" to "The".



   Is your answer  "g/the/s//The/g"? If it is,  you're  really  with
   it.  Let's continue.

        _T_h_e _D_o_l_l_a_r _S_i_g_n ($)


        This symbol denotes just the opposite of the circumflex.  It
   means the end of a line.  Therefore,

                               /?$/

   will locate the first line, from the current line, that ends in a
   "?".

        All right, are you ready for this?  What  is  the  following
   command being used to locate? Answer below.

                             /^attention!$/


   Time's up, let's see if you got this one correct.   Did  you  say
   that  it will locate a line containing only "attention!"?  That's
   exactly what it will do. Or, did you say it will  locate  a  line
   beginning in "attention!" and ending in "attention!"?   I can see
   how you could have come to that conclusion. However, the  follow-
   ing explanation will clear up any confusion. The command

                                - 28 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

                             /^attention!/

   will locate a line which begins with  "attention!".   That's  the
   only  stipulation.  Other characters could follow on the line, or
   the rest of the line could be blank.  Whereas,

                             /^attention!$/

   indicates that "attention!", which is at  the  beginning  of  the
   line, is also at the end of the line with no embedded characters.

        Okay, now you're probably wondering how  you  can  locate  a
   line  containing  the  same string of characters at the beginning
   and at the end with other embedded characters.

        The "." and the "*" can help you with that. These  are  your
   next topics of discussion.

        _T_h_e _I _D_o_n'_t _C_a_r_e _C_h_a_r_a_c_t_e_r


        The period (.) is used to indicate that some character  must
   be  present  at this point in the character string being searched
   for, and that you don't care what the charater  is.  Suppose  you
   issued

                            g/t.e/

   and the buffer contains:

                     Attention!
                     now is the time
                     for all young men
                     to come to the aid
                     of their country.

        In this case the system will  find  a  match  on  all  lines
   except the third. The string matches:

                     tte       in Attention
                     the       in the
                     the       in their

   You're probably thinking that this could pose a  problem  if  you
   want  to  locate  complete  words  that  match  "t.e."   Well, it
   doesn't. All you have  to  do  is  type  spaces  surrounding  the
   string, like this: g/ t.e /





                                - 29 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

        _T_h_e _R_e_p_e_t_i_t_i_o_n _C_h_a_r_a_c_t_e_r (*)


        This symbol is used as a shorthand method of forming   char-
   acter  string expressions consisting of any number of occurrences
   of a single character

                     Example:     /a*/

   will match a string consisting of any number of a's, including no
   a's.   The  "*"  is most useful when used in conjunction with the
   ".", e.g.:

                            /.*/

   can be used to reference an entire line.  Want  another  example?
   the command

                            s/.*/stuff/

   will replace the current line by "stuff." This command,

                            s/.*,//

   will delete all characters in the line up to  and  including  the
   last comma, (Since ".*" finds the longest possible match, it goes
   up to the last comma.) Now can you form  the  search  command  to
   locate a line containing "Attention!" at the beginning and at the
   end with embedded characters?  Write it below.



   If your answer is:  ''/^Attention!.*Attention!$/''  you're  doing
   fine.  Otherwise  go back to the beginning of this section, "Spe-
   cial Characters."

   Okay, let's continue with more good stuff.

        _C_h_a_r_a_c_t_e_r _C_l_a_s_s_e_s '[ ]'


        I know this symbol is familiar to you, It was introduced  to
   you  before as a "wild card" character.  Even though the name has
   changed, the purpose for using it hasn't. It is used as follows:

                       /[1234567]/

        Now, do you recall?  The next line containing any one of the
   digits will be located and displayed.

   Note: Any  characters  you  choose  may  be  placed  inside   the

                                - 30 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

         brackets.  For instance, the circumflex and the dollar sign
         may be  used with the "[]" as follows:

                             g/[1234567]/

         The command :

                             g/[1234567]/

         will locate which lines? Put your answer in the space  pro-
         vided.



         Did you answer any line beginning with  one  of  the  seven
         digits?  If so, you're in good shape.

        _T_h_e _L_i_n_e _R_e_p_e_a_t _C_h_a_r_a_c_t_e_r (&)


        This character is also used as a shorthand method of forming
   character  string  expressions.  It is similar to the (.*) except
   that it is used on the right-hand side of the  'substitute'  com-
   mand  and  refers  to  the context search expression on the left.
   Suppose you wanted to enclose a line in  parentheses,  how  would
   you do it?  One way would be to use the () and ($), such as: '''

                             s//(/
                                or
                             s/$/)/

   An easier way would be:
                            s/.*/(&)/

   which means to replace the current line by itself  surrounded  by
   parentheses.

        Ready for more?  The "&" may be  used  several  times  in  a
   line.  Suppose  the  current  line  is "Now is the time," and you
   issue the command:

                          s/.*/&? &!!/

   the results will be:

                Now is the time ? Now is the time!!






                                - 31 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

        Neat isn't it?  The "&" doesn't have to refer to  the  whole
   line.  Suppose the buffer contains:

                     the end of the world

   and you type the following command:

                  /world/s//& is drawing nigh/

   This will produce::

                  the end of the world is drawing nigh

        _T_h_e _B_a_c_k_s_l_a_s_h _C_h_a_r_a_c_t_e_r


        If one of the special characters has to be  used  in  a  "s"
   command,  you  can  turn  off  its special meaning temporarily by
   preceding it with the backslash (\).  Suppose  the  text  on  the
   current line is ".*\", and you want to replace these symbols with
   their names, then:

                  s/\.\*\\/period asterisk backslash/

   will cause the system to recognize the '.*\' as ordinary  charac-
   ters.

   O.K., it's time to check your  understanding.  Do  the  following
   exercises.























                                - 32 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _E_x_e_r_c_i_s_e_s


        Create the following file using "ed":

   The UNIX Text Editor is really a blessing in disguise for
   people like you and me, whose fingers always seem to end up
   on the right keys at the wrong time:

   1. Now I painlessly produce error free reports.  My boss thinks
   I'm a genius because almost as quickly as he changes his mind,
   I'm giving the modified report back to him;

   The other day he handed me a list of things to do.  I thought,
   "Oh brther, there goes my lunch," until I remembered good
   ole "ed."

   2. Now, I easily correct the many errors that just seem to
   pop in my reports. I can locate any string of characters, even
   those with special characters such, as *,&,[, etc., in a snap.
   Even locating digits (12345) presents no problem, and
   copying parts of a report is done in a breeze.

   Thanks UNIX for ed.

   Use the above file to do the following:



    1.  Change all sentences that begin in "the" to "The."

    2.  Change all sentences that end in ":" or ";" to a ".".

    3.  Delete all digits from the file.

    4.  Replace each "*" with "$."

    5.  Place a "$" at the beginning of each line.

    6.  Place a "*" at the end of each line not ending in a period.

    7.  Change the last line such that it reads,  "Thanks  Unix  for
        ed!  It's just what I needed."








                                - 33 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _A_n_s_w_e_r_s


        If you are unable to perform the above exercises, review the
   solutions  (commands)  below.  If you still have questions please
   contact the instructor.


                  1. g/the /s//The/gp

                  2. g/[:;]$/s//./gp

                  3. g/[1234567890]/s///gp

                  4. g/\*/s//$/gp

                  5. g//s//$/gp

                  6. v/\.$/s/.*/&*/gp

                     Observe: Since the expression following
                     the "v" isn't on the lines located the
                     first string in the "s" command can't
                     be "//".

                  7. $s/\./! It's just what I needed./p





   All right, you've finished Module I. The commands  used  in  this
   module  are  listed  on  the  next page. Look them over carefully
   _____ then go back and review the objectives for Module  I.  When
   you are ready, go on to the Module Test.
















                                - 34 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _S_u_m_m_a_r_y _o_f _C_o_m_m_a_n_d_s



    1.  [line-number]a                (append)

    2.  [start,end]c                  (change)

    3.  [start,end]d                  (delete)

    4.  e <filename>                  (edit)

    5.  f                             (file)

    6.  g/---/commands                (global)

    7.  [line-number]i                (insert)

    8.  <start,end>m<line-number>     (move)

    9.  [start,end]p                  (print)

   10.  s/string1/string2/            (substitute)

   11.  [line-number]r [filename]     (read)

   12.  [line-number]w [filename]     (write)

   13.  /---/                         (context search)

   14.  v/---/commands                (global)

   15.  ?---?                         (reverse context
                                       search)

   16.  .=                            (dot value)

   17.  q                             (quit)

   Note: The period ends the "a," "c," and "i" commands.











                                - 35 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _M_o_d_u_l_e _I _T_e_s_t

       DIRECTIONS:  The "Summary of Commands" sheet is the only  aid
       you can use in taking this test.  Minimum passing score is 10
       of 15 correct.



    1.  The command used to access the Unix Text Editor is

    2.  The command used to leave the Unix Text Editor is

    3.  ______________ is the command used to create a file  or  add
        lines of text to a file in the buffer.


    4.  The command:

                            .c
                            <text>
                            .

        will change which line of text in the buffer?

    5.  Write the command to insert lines of  text  before  the  3rd
        line in the buffer.

    6.  Write the command to place the contents of the buffer into a
        file named "temp".

    7.  Write the command used to delete lines  5  thru  10  in  the
        buffer.

    8.  Write the command to move lines 3 thru 8 to the end  of  the
        buffer.

    9.  Write the command to change and display all lines containing
        the characters "shiling" to "shilling."

   10.  Write the  command to create the file "junk" from  lines  20
        thru 50 of the current file.

   11.  Write the command to insert the file  "junk"  following  the
        10th line of the current file

   12.  You are editing two files, "temp" and "hold." Write the com-
        mand to place "hold" into the buffer.

   13.  What command is used to locate all lines not containing  the
        specified string of characters?

                                - 36 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   14.  What is the purpose of the following commmand:

                  g/\./s//,/gp

   15.  ".=" is used to display what marker?



   Correct your test by using the key found on the  next  page.   If
   you  miss more than 5 questions, please review this module before
   continuing to module II. Contact  your  instructor  if  you  need
   additional help.








































                                - 37 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _A_n_s_w_e_r_s _t_o _M_o_d_u_l_e _I _T_e_s_t



    1.  _e_d is the command used to access the Unix Text Editor.

    2.  _q is the command used to leave he Unix Text Editor.

    3.  _a is the command used to create a file or add lines of  text
        to a file in the buffer.

    4.  _T_h_e _c_u_r_r_e_n_t _l_i_n_e in the buffer will be changed by  the  com-
        mand:
                         c
                         <text>
                         .

    5.  _3_i (which inserts the text that follows just before the  3rd
        line or "2a," which inserts the text that follows just after
        the 2nd line) is the command used to insert  lines  of  text
        before the 3rd line in the buffer.

    6.  _w _t_e_m_p is the command used to  place  the  contents  of  the
        buffer into a file named "temp."

    7.  _5,_1_0_d is the command used to delete lines 5 thru 10  in  the
        buffer.

    8.  _3,_8_m$ is the command used to move lines 3 thru 8 to the  end
        of the buffer.

    9.  _g/_s_h_i_l_i_n_g/_s//_s_h_i_l_l_i_n_g/_g_p  is  the  command  to  change   and
        display  all  lines  containing  the characters "shiling" to
        "shilling."

   10.  _2_0,_5_0_w _j_u_n_k is the command used to create  the  file  "junk"
        from lines 20 thru 50 of the current file.

   11.  _1_0_r _j_u_n_k is the command used to insert the file "junk"  fol-
        lowing the 10th line of the current file.

   12.  _e _h_o_l_d is the command used to place the file "hold" into the
        buffer.

   13.  _v is the command used to locate all lines not  containing  a
        specified string of characters.

   14.  _T_o _c_h_a_n_g_e _a_l_l _p_e_r_i_o_d_s _t_o _c_o_m_m_a_s _a_n_d _d_i_s_p_l_a_y _t_h_e  _r_e_s_u_l_t_s  is
        the purpose of the command: g/\./s//,/gp.


                                - 38 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   15.  _T_h_e _c_u_r_r_e_n_t _l_i_n_e _n_u_m_b_e_r is displayed by .= .



















































                                - 39 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


                         _M_O_D_U_L_E _I_I -- _N_R_O_F_F


        This module covers UNIT III objectives 4 and 5.

        _O_b_j_e_c_t_i_v_e_s


        After completion of this module, you will be able to:

    1.  Use the proper command to gain access to nroff.

    2.  Display a file beginning at a specified page.

    3.  Terminate output after a specified page.

    4.  Control the length of the pause between each page of output.

    5.  Control page formatting:
            a.  page length
            b.  page mumbering
            c.  begin output on a new page

    6.  Control text placement on a line.

    7.  Control vertical spacing.

    8.  Determine line length.

    9.  Indent automatically.

   10.  Define and execute macros.

   11.  Define character strings.

   12.  Underline text.

   13.  Generate headings.

   14.  Obtain automatic numbering of pages, paragraphs and lines.











                                - 40 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _I_n_t_r_o_d_u_c_t_i_o_n _t_o _N_r_o_f_f


        In this module, you will learn to format the  text  in  your
   files through nroff.  This feature facilitates and expedites data
   entry.

        Nroff is a text processor. (The term Nroff is short for  New
   Runoff.) It accepts lines of text interspersed with lines of for-
   mat control commands  and  formats  the  text  into  a  printable
   paginated document.

        Nroff offers unusual freedom in document  styling,  such  as
   arbitrary  style headers and footers; multiple automatic sequence
   numbering for paragraphs, sections,  etc.,  automatic  indenting;
   and underlining.

        The form of the command is:

                  nroff {options} <filenames>

   Where "options" represent any number of optional  arguments  (see
   below), and "filenames" represent the list of files to be format-
   ted. For instance,

                       nroff -o6- junk

   will display the file "junk" beginning with the 6th page.



            _O_P_T_I_O_N_S            _E_F_F_E_C_T

        -olist           Begin  output  at  the  first  page  number
                         listed,  (whether or not the page number is
                         to be printed), and print all listed pages.

                         Example: nroff -o8- junk
                         will display the file "junk" beginning with
                         the 8th page.

                         Example: nroff -o1,20 junk
                         will display the first  and  and  twentieth
                         pages of the file "junk."

                         Example: nroff -o3,5,8-13 junk
                         will display pages 3,5,and   8  through  13
                         inclusive.



                                - 41 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

        -nN              Number   the   first   output    page    N.
                         Example: nroff -n3 junk
                         will cause the first page displayed  to  be
                         numbered "3" instead of "1."


        -s               Stop between pages.   The  system  displays
                         one  page  at a time.  You must depress the
                         return key after each page is displayed, in
                         order  to  display the next page.  The com-
                         mand is as follows: nroff -s junk
        -T                Informs nroff of the terminal type so that
                         it  can take advantage of special features.
                         The specific options are:

                              -T832     Anderson Jacobson AJ832
                              -T100     Qualterm X100
                              -T300Q    GSI 300Q

                         The terminal type default  option  is  -T37
                         (Teletype Model 37).

   What will be the result of the following command:

                       nroff -s -o5-50 junk

   Answer:


   You're correct if you said the system will display pages  5  thru
   50 one page at a time.

        _N_r_o_f_f _C_o_m_m_a_n_d_s


        Nroff also  provides  several  commands  that  are  used  to
   enhance  text  formatting.  These commands are typed interspersed
   with lines of text.  All commands must begin in the  first  posi-
   tion  of  a  line.  Otherwise, the command will be interpreted as
   text.

        Nroff is used in conjunction with another  file,  "tmac.nm."
   This  file  contains  a set of pre-defined macros which will make
   life easier for you. What is a macro? We'll get to that  shortly.
   To  access this file, put the following line as the first line of
   your file:






                                - 42 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

                       .so /usr/lib/tmac.nm

   Caution: If this line is omitted, certain commands  mentioned  in
   this unit will not be executed.

   Example of an nroff file named "test":

                  .so /usr/lib/tmac.nm
                  .bp
                  .ll 80
                  .in 5
                  This is an Nroff file which consists of Nroff com-
                  mands  and  lines of text.  The Nroff commands may
                  be interspersed with lines of text throughout  the
                  file.

   To display the file in its formatted form, type:

                       nroff -s test

        _P_a_g_e _C_o_n_t_r_o_l _F_o_r_m_a_t_t_i_n_g


        The following commands are used to format the  output  page.
   They may be placed throughout the text in your file.

    1.  page length (.pl)

        This command allows you to specify the number  of  lines  of
        text to be placed on a page.  The form of the command is:

                               .pl 50

        In this instance "50" indicates the number of  output  lines
        to  place on each page. This includes the nine lines used by
        the system for headers and  footers.   Therefore,  you  must
        specify  the  number  of  lines of text to be placed on each
        page, plus nine.

        If this command isn't used, the system places  66  lines  of
        output on each page provided that many exist in the file.

    2.  Begin page (.bp)

        This command, when encountered, causes the system  to  eject
        the current page and begin a new page.  The form is:

                               .bp
                          or
                               .bp N


                                - 43 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

        The second form, if used, causes the system to begin  a  new
        page  and to number the page using the specified number.  If
        the number isn't specified, the system begins its  numbering
        with 1.

                           Example: .bp 5

        will cause the system to  eject  the  current  page  and  to
        number the new page 5.

    3.  Page numbering (.pn)

        You're probably thinking, "Sure that's fine, but what  do  I
        do if I want page numbering to begin at something other than
        1, and I don't want a new page?"

        This is where th 'pn' command proves  its  usefulness.   The
        form of the command is:

                               .pn N

        where "N" indicates the number to use to begin numbering the
        pages.  Here is an example:

                               .pn 20

        Can you think of  another  way  this  can  be  accomplished?
        Answer in the space provided.



        Sure you can, page numbering can be  specified  directly  in
        the nroff command, as shown below:

                            nroff -n20 junk


    4.  Page offset (.po)

        This command is used to prepare spaces to each output  line.
        The command format is:

                               .po N

        where "N" indicates the number of  spaces  to  place  before
        each  line.   That is, the page image is moved 'N' spaces to
        the right.


   Notes: 1.The ".po" command  should  be  preceded by a ".br" if it
            is placed between lines of text.

                                - 44 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

          2.The no-break character (') can  also  be  used with  any
            of these commands.
   Ready to check your knowledge?  Do the following exercises.

        _E_x_e_r_c_i_s_e

   Create a file from the following text:

        You have been approved by the Department to take one or more
   courses  at  a  local  college  or  university.  Your tuition and
   laboratory fees (2/3 in the case of the Department's  after-hours
   program)  are  paid  by  contract.   You  must pay all other fees
   (matriculation, registration, etc.) and purchase your  own  books
   and supplies.

        You are expected to comply with all DOD and university regu-
   lations  and to earn satisfactory grades.  In addition to meeting
   these requirements, you must maintain at least a  C+  average  in
   order  to be eligible for continued consideration for agency tui-
   tion assistance.


   Note: Did you remember to include this line?

                     .so /usr/lib/tmac.nm



    1.  Display the above file using nroff, such that:
            a.  Each paragraph appears on a separate page.
            b.  Page numbering begins with 3.
            c.  A pause is generated before each page.

    2.  Display the file again, such that:
            a.  5 lines of text are placed on each page.
            b.  The last half of  the  file  is  displayed  with  an
                offset of 15.















                                - 45 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _T_e_x_t _P_l_a_c_e_m_e_n_t _C_o_n_t_r_o_l


        The next commands allow you to determine how and  where  the
   output  lines  are  to  appear on the page.  These commands elim-
   inate the task of setting margins, centering  lines,  spacing  to
   indent, spacing to generate blank lines within the text, etc.

        _B_r_e_a_k (._b_r)


        The ".br"  command causes the system to  begin  a  new  line
   with the text following this command. Suppose your directory con-
   tains the following file, "junk":

                     Now is the time
                     for all men
                     to come to the aid
                     of their country.


   And, you issue the command:

                       % nroff junk

   the system will display:

   Now is the time for all men to come to the aid of their country.

        The system will automatically place  characters  on  a  line
   until the line is filled unless otherwise directed, such as:

                      now is the time
                      .br
                      for all men
                      .br
                      to come to the aid
                      .br
                      of their country.

   Now if you issued the command:

                       % nroff junk

   the results displayed would be:

                     Now is the time
                     for all good men
                     to come to the aid
                     of their country.

                                - 46 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _F_i_l_l _o_u_t_p_u_t _l_i_n_e_s (._f_i)


        This command places the system  in  the  "Fill  Mode"  which
   directs  the  system to place characters on the output line until
   the maximum number of characters has been placed there.  This  is
   the action normally taken by the system. Therefore, you would use
   this command only if this condition needed to be reactivated.

   Note: The number of characters to place on a line depends on  the
         value  of the line length parameter. This parameter is nor-
         mally set to 65; however, it may be reset by you.

        Now, before you look at an example, take a look at the  next
   command.

        _N_o-_f_i_l_l _o_u_t_p_u_t _l_i_n_e_s (._n_f)


        This command causes subsequent output lines to be  displayed
   exactly  as  they  appear in the file.  No regard is given to the
   maximum line length.

   For example, when your file contains

                     Now is the time
                     for all good men
                     to come to the aid
                     of their country.
                     .nf
                     Now is the time for
                     all good men to come
                     to the aid of their
                     country.
                     .fi
                     Now is the time
                     for all good men
                     to come to the aid
                     of their country

   The results will be:

                     Now is the time for all good men to come to the
                     aid of their country
                     Now is the time for
                     all good men to come
                     to the aid of their
                     country
                     Now is the time for all good men to come to the
                     aid of their country

                                - 47 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   Got the idea?  the ".nf" command has  a  effect  similar  to  the
   ".br" command doesn't it?

        If you can't discern how the results were  obtained,  please
   re-read the preceeding two sections.

        _A_d_j_u_s_t_i_n_g _o_u_t_p_u_t _l_i_n_e_s (._a_d)


        Nroff even has a command which can be used  to  left-adjust,
   to center, or to right-adjust your text.  The command is:

                            .ad c

   where "c," the adjustment type character, is used to indicate the
   manner in which the text is to be adjusted on the output line.

   If the adjustment type character is a/an:

            1. "r," the text will be right-adjusted, aligned
               and the left margin will be ragged; e.g., ".ad r";

            2. "c," the text will be centered -- both margins
               will be ragged; e.g., ".ad c";

            3. "n," the normal (default) is restored -- both
               margins will be adusted or even; e.g.,"ad n."

   Note: The "Fill Mode" must be turned on before  the  system  will
         recognize and execute the adjustment command.

        _N_o_a_d_j_u_s_t _c_o_m_m_a_n_d (._n_a)


        This command turns the adjustment off.  The  text  following
   will  be  left-adjusted. That is the left margin will be even and
   the right margin will be ragged.  Output line filling will  occur
   only if the "Fill Mode" is turned on.

        _C_e_n_t_e_r_i_n_g _O_u_t_p_u_t _L_i_n_e_s (._c_e _n)


        This command is also used to center output  lines.  However,
   unlike  the  adjustment  command,  the lines are centered just as
   they appear in the file  -  no  line  filling  takes  place.  "n"
   denotes  the number of lines to be centered.  If "n" isn't speci-
   fied, one line is centered.





                                - 48 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

        _V_e_r_t_i_c_a_l _S_p_a_c_i_n_g


        As you have seen, the system will automatically single space
   your output. But, what about double or triple spacing?  Sure, you
   can hit the RETURN KEY two or  three  times  in  succession,  but
   wouldn't  it  be  much easier if you could program your file such
   that the system will perform automatic vertical spacing?

        Well, you can by using the "ls" (line spacing) command which
   has the form:

                            .ls n

   where "n" denotes the number of lines, less one, that the  system
   will leave blank following each output line. For example, you are
   going to display the following file using nroff:

                     .so /usr/lib/tmac.nm
                     .ls 3
                     Now is the time
                     for all young men
                     to come to the aid
                     of their party

   The result will be:
                     Now is the time


                     for all young men


                     to come to the aid


                     of their party

   You're probably thinking, "that's fine, if  you  want  the  whole
   file  to  be evenly spaced." Not so; take a look at the following
   file:

                     .so /usr/lib/tmac.nm
                     .nf
                     .ls 3
                     Now is the time
                     for all young men
                     .ls 1
                     to come to the aid
                     of their party



                                - 49 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   What do you think the results will be?  Write your answer below.


   You're absolutely correct, if your answer agrees with:

                      Now is the time


                      for all young men


                      to come to the aid
                      of their party

   Just reuse the "ls" command with a different value and you change
   the number of blank lines inserted after each output line.

        _B_l_o_c_k_s _o_f _v_e_r_t_i_c_a_l _s_p_a_c_e


        You may also direct the system to generate blocks  of  space
   within  your  file. That is, you can cause several blank lines to
   be inserted at cause points throughout the file.  Thus,  you  can
   vary  the  distance  between the heading and the text or to cause
   certain items, such as examples, to be conspicuous. The  form  of
   the command is:

                            .sp n

   where "n" indicates the number of lines to leave blank when  this
   command  is encountered. Here is an example of how the command is
   used.

                     .so /usr/lib/tmac.nm
                     This is my heading
                     .sp 4
                     This is my text

   This would cause 4 blank lines to be inserted between the heading
   and the first line of text.

   Notes: (1) You must reuse this command each time you want a block
              of lines inserted.

          (2) If "n" isn't specified, it is assumed to be 1.







                                - 50 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

        _C_o_n_t_r_o_l _C_h_a_r_a_c_t_e_r_s


        Let's pause a moment to discuss two very significant charac-
   ters before beginning our discussion of the nroff commands

        The period (.) and the apostrophe (')  are  referred  to  as
   control characters.  All nroff commands begin with either the "."
   (break character) or  the  "'"  (no-break  character).  Any  line
   beginning with either of the characters is called a control line.

        The "." causes the command which follows to be  executed  at
   the  point  it is encountered within the text. This may cause the
   system to output a partially filled line. Let's assume  you  have
   the following text:

    Come one, come all, the time is now. Now is the time for all
    .br
    to come to the aid of their country.

   Note: "br" indicates that the next line  of  text  begins  a  new
         line;  otherwise   the   system will treat all lines as one
         continous stream.

        Now suppose that the line before the ".br" is  too  long  to
   fit  on the current output line. Let's see how the system handles
   this:

   come one, come all, the time is now.  Now is the time
   for all
   to come to the aid of their country.

        Okay, let's change the ".br" to "'br" and see what  happens.
   The text would now be displayed as:

   come one, come all, the time is now. Now is the time
   for all to come to the aid of their country.

        The   "'"   suppresses   the   output    of    a   partially
   filled   line   until   after  the command  following   the   "'"
   has   been executed. Before continuing with the next command, try











                                - 51 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   to answer these questions correctly.

        _E_x_e_r_c_i_s_e_s

   Differentiate between using:



    1.  ".br" and ".sp" to begin a new line.

           answer:

    2.  ".ls" and ".sp" to obtain vertical spacing.

           answer:

    3.  ".ad c" and ".ce".

           answer:

    4.  ".br" and ".nf".

           answer:





























                                - 52 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _A_n_s_w_e_r_s



    1.  ".sp" causes a blank line to  be  inserted  in  addition  to
        beginning a new line; ".br" just begins a new line.

    2.  ".ls" can be specified once and the system will insert  that
        number  of  blank  lines  after  each output line within the
        file.  ".sp" must be specified each time blank lines are  to
        be inserted.

    3.  ".ad c" will center lines with  line-filling  taking  place;
        ".ce" centers lines without line-filling.

    4.  ".br" must be specified before each line which is to begin a
        new  line;  ".nf"  needs  to  be  specified only once for an
        unlimited number of lines (until the ".fi" command  is  exe-
        cuted).
   ****If you answered any of these questions  incorrrectly,  please
       re-read the appropriate sections.

        _L_i_n_e _l_e_n_g_t_h (._l_l)


        Another nroff nicety is being able to  specify  the  maximum
   length  of  each line in your file, which if not otherwise speci-
   fied is 65 characters. At ten characters per inch,  this  amounts
   to 6 1/2 inches.

   The command used to change the line length is:

                            .ll n

   where "n" denotes the maximum number of characters to place on  a
   line.   There are no restrictions on the number of times the line
   length may be changed within a file; therefore,

                            <text>
                            .ll 80
                            <text>
                            .ll 132
                            <text>
                            .ll 65
                            <text>

   is quite valid.




                                - 53 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

        _A_u_t_o_m_a_t_i_c _i_n_d_e_n_t_i_n_g  (._i_n)


        Automatic indenting may also be obtained by using the  ".in"
   command.   Just think how using this command will accelerate data
   entry. No more counting and spacing over to a certain  column  or
   trying  to  recall  how many spaces to indent to ascertain proper
   alignment.  As an example:

                            .in 15

   will indent each subsequent line 15 spaces until the  command  is
   re-used with a different value.  Now you try it.  Format the fol-
   lowing paragraph such that the first line is indented  10  spaces
   and the succeeding lines 5 spaces:

             Nroff is the program to really utilize,
             it eliminates many tedious task to your surprise.
             Not only does it help you to economize,
             your time,your effort, and likewise;
             but brings satisfaction to your boss' eyes.
             Which can be only good, I would surmise.

   Put your answer in the space provided.



   You're  correct if your answer is:

             .in 10
             Nroff is the program to really utilize,
             .in 5
             it eliminates many tedious task to your surprise.
             Not only does it help you to economize,
             your time, your effort, and likewise;
             but brings satisfaction to your boss' eyes.
             Which can be only good, I would surmise.

        Okay, let's continue.  Do you know that you can also  indent
   just  a  single  line? Yes, you can by using the ".ti" (temporary
   indent) command.  Let's illustrate its use by  referring  to  the
   above problem and indenting lines 1,3, and 5.










                                - 54 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   This task is accomplished in the following manner:
        .in 5
        .ti 10
        Nroff is the program to really utilize,
        it eliminates many tedious task to your surprise.
        .ti 10
        Not only does it help you to economize,
        your time, your effort, and likewise;
        .ti 10
        but brings satisfaction to your boss' eyes.
        Which can be only good, I would surmise.

   Note: (1) All lines will be indented  5  spaces  unless  directly
             preceeded by the "ti" command.

         (2) The .ti command  can  be  used  with  the  plus(+)  and
             minus(-)  symbols  to  temporarily increase or decrease
             the indent  a  specified  number  of  spaces  from  the
             current indent.

        _M_a_c_r_o_s


        Macros afford you a tremendous  amount  of  flexibility  and
   control  over  the  order of execution of "nroff" commands within
   your files.

        A macro is a named  set of one or more  lines  that  may  be
   invoked when the name is referenced or by having reached a speci-
   fied line on the page.

        The set of lines used to compose the macro  may  be  command
   lines  or textual lines.  Macro names are arbitrarily choosen and
   are one or two characters long.

        _D_e_f_i_n_e _C_o_m_m_a_n_d


        Macros are defined by using the "define" command  which  has
   the following form:

                       .de <name>
                       <commands/text>
                       ..

   where ".de" defines the macro whose name is "<name>."   Following
   the macro definition is the commands /text to be contained within
   the macro. ".."  ends the macro definition. Here is an example of
   the use of the "define" command.



                                - 55 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

                            .de xx
                            .pl 50
                            .nf
                            .ls 2
                            ..

   Only when the macro "xx" is invoked will the  commands  contained
   within  be  activated.   Now  the question is, how can a macro be
   invoked?  A macro may be invoked by a macro reference or by  set-
   ting a "line trap."

        _M_a_c_r_o _R_e_f_e_r_e_n_c_e


        A macro is invoked when the name of the macro is referenced.
   For instance, to invoke the macro in the above section, you would
   place the command, ".xx," just before the text on which the  com-
   mands in the macro "xx" are to be applied.

        _L_i_n_e _T_r_a_p_s


        The second method of invoking a macro is by setting  a  line
   trap.   Don't panic! This isn't as awesome as it sounds.  A "line
   trap" is just a command which directs the system to invoke a cer-
   tain  macro when a specified line on the page is reached. Here is
   an example:

                            .wh 5 xx

   This reads, when line 5 is reached invoke  macro  "xx."   If  the
   number  specified  is  0 or positive, it refers to the top of the
   page.  The number 5 means the fifth line  from  the  top  of  the
   page.  What do you think 0 refers to? Answer below.



   That's correct, 0 refers  to  the  top  of  the  page.   Negative
   numbers  may  also  be  used  to  reference the bottom of a page.
   Hence, -7 means the seventh line from the bottom of the page.

        The ".wh" command is usually placed at the  beginning  of  a
   file following the macro definitions.  Once set, a line trap will
   be automatically executed for each subsequent page.   Also,  more
   than  one  line trap may be set referring to the same macro. Here







                                - 56 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   is how it could be done:

                       .wh 0 zz
                       .wh -7 zz
                       .de zz
                       'tl ''UNCLASSIFIED''
                       ..

   This would cause the word 'UNCLASSIFIED' to be  centered  at  the
   top and at the bottom of each output page.

   Note: (1) The command  ".tl"  left  adjusts,  centers  and  right
             adjusts  within  three  fields.  The  three  fields are
             defined by single quote marks.  This  command  will  be
             described in more detail at a later point.        (2) A
             macro is redefined when its name is  used  in  a  later
             "define" command.

        _A_r_g_u_m_e_n_t_s


        Textual values may be passed to a macro to be  displayed  at
   the  time  the macro is invoked.  These values are referred to as
   arguments and may be modified each  time  the  macro  is  called.
   Let's look at the following example to more clearly explain argu-
   ments:

                     .de A
                     Today is \\$1 the  \\$2 of \\$3
                     ..

   where "\\$1,\\$2,\\$3" represent arguments.  There may be as many
   as  nine  arguments in a macro.  The values to be substituted for
   these arguments are passed in the macro reference  command.  Look
   at the following example:

                     .A Tuesday 4th July

   This would display the line:

                  Today is Tuesday the 4th of July

   You will notice that the first value replaces the first argument,
   the  second  value  the  second argument, etc.  The next time the
   macro "A" is called, different values may be substituted for  the
   arguments.

   Note: The  substitution  values  in  the  macro   reference   are
         separated  by  a  blank.  Therefore,  if  a  value contains
         blanks, it must be enclosed in double quote marks. Here  is
         how it is accomplished:

                                - 57 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

                       .de zu
                       Date: \\$1
                       .br
                       To: \\$2
                       .br
                       From: \\$3
                       .br
                       Subject: \\$4
                       ..
                       .zu "Nov 27, 1977" E53 E5 Promotions


   Note: If the desired substitution values are too long to  fit  on
         one  line,  type  "\ <carriage return>" (concealed new line
         character) and continue to the next line. The last  charac-
         ter on the line to be continued should be "\".

        _D_e_f_i_n_i_n_g _c_h_a_r_a_c_t_e_r _s_t_r_i_n_g_s


        Another beneficial feature is called character  strings.  It
   is  especially  useful  if you have to type a label or some other
   identification tag several times throughout the file. A character
   string  is  very  similar to a macro. That is, it requires a name
   which is one or two characters in length; and it  may  be  refer-
   enced any number of times even thought it is defined only once. A
   character string is defined by using:

                       .ds <name> string

   where "<name>" is the name of the character string  and  "string"
   is  the  characters used to form the character string.  After the
   character string has been defined, it may be referenced by:

                   \*<1-character name>    eg.\*A
                          or
                    \*(<2-character name>   eg. \*(AB

   Let's assume that you are typing a report  consisting of domestic
   messages,  and  each  message  contains  a  code  which indicates
   whether the message was sent or received by  the  United  States.
   You  must  interpret  the  code  by  printing  either "sender" or
   "receiver" at the end of each message.









                                - 58 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


                   _s_o_l_u_t_i_o_n:

                            |
                            |
                            .ds s sender
                            .ds re receiver
                            |
                            |
                            <message received by the U.S.>
                            \*(re
                            <message sent by the U.S.>
                            \*s
   Note: Of course, the longer the string, the greater the benefits.
   All  right,  let's  review  your progress. Do the following exer-
   cises.

        _E_x_e_r_c_i_s_e



    1.  Take the file employed in the exercise on  page  47  (adding
        the  information  introduced in item c (below) and format it
        as follows:
            a.  The word "SECRET" centered at the top and bottom  of
                each page.
            b.  Your name, organization, and secure phone number  on
                the  next  output line.  Note: Use arguments to pass
                the information
            c.  The following text is  double-spaced  and  centered.
                Also,  display  "this  line is encoded text," before
                each line containing an "i."

                text:    Blue    Qoqz    Poue    zekf
                         Jogw    newk    fikd    meth
                         cikf    vebi    fewr    wunq
                         virx    fikd    wegn    wudg
                         holb    humb    nydn    hiof
                         wyuw    kykw    wube    gawr
                         wyln    qabo    gyuk    blue
            d.  Each line of text is placed  on  a  separate  output
                line.

    2.  Display the file constructed in #1 using nroff.

   Compare your solution with the one on the following page.






                                - 59 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _S_o_l_u_t_i_o_n _t_o _t_h_e _E_x_e_r_c_i_s_e

                 .wh 0 zz
                 .wh -7 zz
                 .de zz
                 'tl ''SECRET''
                 'sp 2 (leaves blank spaces after classification)
                 ..
                 .de za
                 Name:\$1
                 .br
                 Organization:\$2
                 .br
                 Secure Phone:\$3
                 .br
                 ..
                 .za ''Your Name'' Organization Phone
                 (text from previous exercise is entered here)
                 .sp (assures that the end of preceeeding
                      text is not operated upon by the follow-
                      ing commands)
                 .ls 2
                 .ad c
                 .ds i This line is encoded text
                 .nf

                 blue    qoqz    pove    zefk
                 \*i
                 jogw    newk    fikd    meth
                 \*i
                 cikf    vebi    fewr    wunq
                 \*i
                 virx    fikd    wegn    wudg
                 \*i
                 holb    humb    hiof    nydn
                 wyuw    kykw    wube    gawr
                 wyln    qabo    gyuk    blue


   Note: ".br" could have  been  used  following  each  output  line
         instead  of  using  the ".nf" command.  Also, your solution
         does not have to  be  identical  to  this  solution  to  be
         correct.








                                - 60 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        _U_n_d_e_r_l_i_n_i_n_g _t_e_x_t (._u_l)


        Underlining can be achievied by backspacing and overstriking
   with the desired character; however, this method is not only time
   consuming but may cause alignment problems if the line has to  be
   modified.   The  underline  command  will automatically underline
   each word within the specified line.  The form of the command is:

                            .ul <n>

   where "<n>" denotes the next n lines.  If "<n>" is omitted,  only
   the  next line is underlined.  As an example, suppose you wish to
   underline the heading in the last exercise;  the  file  could  be
   modified thus by:
                        .de zz
                        .in 24
                        \\$1 \\$2 \\$3
                        .sp 5
                        .ul
                        encoded lines
                        .br
                        ..

   Note: On a CRT Terminal (Delta Data or Superbee) the system  will
         display  only  the  character used for the underlining, not
         the  characters  being  underlined  unless  routed  to  the
         printer.

        An alternative to routing the output to the printer would be
   to  route it through the "br" program; this causes the underlined
   lines to appear highlighted. (Example: nroff <filename>|br)

        _E_x_e_r_c_i_s_e



    1.  Modify your solution to the  problem  in  the  previous sec-
        tion   to   reflect   the  insertion  of  the underline com-
        mand.

    2.  Display the file using nroff, nroff with br, and nroff  with
        opr.








                                - 61 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


   _G_e_n_e_r_a_t_i_n_g _T_i_t_l_e_s


        The ".tl" command is used to  generate  titles  or  headings
   that will be automatically right-adjusted, left-adjusted, or cen-
   tered.  The form of the command is:

                    .tl 'left'center'right'

   where the single quote is the field delimiter and  left,  center,
   and  right are character strings.  Okay, suppose you want to gen-
   erate a header which displays the "date" to the left; the  "title
   of  the  document"  in the center; and "your organization" to the
   right, then you would form the title  command  in  the  following
   manner:

                 .tl '06/12/78'encoded lines'E53'

   now, let's form the header such that "encoded lines" is omitted.

                     .tl '06/12/78''E53'

   The above command would left-adjust the date and right-adjust the
   organization designator.

   what will be the results of the following?

                      .de hd
                      .tl '06/12/78''E53'
                      .sp 3
                      .tl ''encoded lines''
                      ..
                      .wh 0 hd

        Let's see how you did.  If your answer is: the  system  will
   display the date and organization at the top of the page, and the
   title line centered 3 lines from the top, you are quite  observa-
   tive.   If  your  answer  differs, it is probably with the second
   header; so let's closely examine it.  The first two adjacent sin-
   gle quotes indicate that there is no left string to be displayed;
   therefore the field  is  skipped.   Next  the  center  string  is
   displayed  in  the  center  of  the  line, and the right field is
   skipped because of the next two adjacent quotes.

        Now try another one.  Where will the date be displayed  when
   the following command is executed?

                       .tl '''06/12/78'

   At the right -- by george, you've got it.

                                - 62 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   Note: (1) Any character may  be used as the field delimiter.
         (2) The title command may appear inside a macro or  outside
             a  macro; when outside a macro the title command should
             be directly preceeded a ".br".

   _P_a_g_e _n_u_m_b_e_r _o_p_t_i_o_n


        You can direct the system to display the current page number
   by using a "%" in the title command. For instance,

                     .tl '06/12/78''page %'

   will yield:

             06/12/78                        page 1

   The page number will be incremented by  1  with  each  succeeding
   page.   You  now have the page number displayed at the top and at
   the bottom of the page.

   Note: The "%" may appear in either of the three fields, not  only
         the right field.

   Now let's determine how to use the page number option.

                      Example:.de xx
                              .tl '''page %'
                              ..
                              .wh 0 xx
                              .wh -7 xx

   will display the page number at the top and at the bottom of  the
   page.

   _D_a_t_e _O_p_t_i_o_n


        You can direct  the  system  to  display  the  current  date
   automatically by referring to the following pre-defined names:

                       mo - current month
                       dy - current day
                       yr - current year








                                - 63 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   These names are referenced in the following manner:

                            \\n(mo
                            \\n(dy
                            \\n(yr

   Now let's reference the above in the title command.

             .tl '\\n(mo-\\n(dy-\\n(yr''page-%-'

   would yield.

             5-24-78                         page-1-

   This assures that whenever the file  is  displayed,  the  current
   date will appear in the header.

   Note: The hyphens are not required in the format; they  are  used
         only  as   separators. Any character or group of characters
         could also have been specified, for example .tl 'Today is:

              .tl 'Today is:\\n(mo/\\n(dy/\\n(yr'''
              would yield
              Today is: 5/24/78

   _C_h_a_r_a_c_t_e_r _T_r_a_n_s_l_a_t_i_o_n (._t_r)


        Nroff really outdid itself with this feature. You can  actu-
   ally type one character and have the system display another char-
   acter in its place.  This feature could be an invaluable tool  to
   the analyst.The form of the command is:

                          .tr abcd....

   where "a" will be displayed as "b"; and "c" will be displayed  as
   "d,"  etc.  If an odd number of characters is specified, the last
   one will be displayed as a space.  A common use of  this  command
   is  to  provide  nonadjustable  spaces.  Hold it! Don't lose your
   cool, an explanation follows.  When the fill mode is  turned  on,
   the  system will sometimes throw in additional spaces in order to
   fill the line with the specified maximum number of characters, or
   a  line may have to be continued because it exceeds the specified
   maximum line length.  In either case the above actions  are  per-
   formed  only  where  a  space is present. Therefore, if you don't
   wish to have certain words or phrases separated by more than  one
   space,  you  could use the ".tr/" command, ".tr/ ". Now any place
   you didn't want extraneous spaces or an  interruption  you  would
   place a "/". The following shows what is meant:

                       Mr/Edward/Joness

                                - 64 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

                       fig./25
                       2/+/x/=/y

   Here a space is displayed each time a "/" is  encountered.  Addi-
   tionally, the "/" used as a separator causes the system to inter-
   pret any number of words or symbols as a single  entity  so  they
   will not be moved apart nor split across two lines.

   Now, analyze the following:

                            .tr iIaA

   Put your answer here.



   Is your answer, "All lower-case i's  and a's will be displayed as
   upper  case  I's  and  A's"?  If  so,  very  good. If your answer
   differs, please review this section.
   Note: Many macro packages, such as "nm," "mm" and "ms",  use  the
         convention  of  ~  as  a non-adjustable space. That is, the
         line:

                       .tr ~

         appears in each package.  More  will  be  said  about  this
         feature at a later point.

   _D_e_f_i_n_i_n_g _T_a_b_s


        Text to be columnized doesn't present a  problem  to  nroff.
   It  provides  commands which allow you to establish tab settings.
   They are:

                          .ta n,...
                          .fc a b

   The "ta" command is used to specify the  tab  stop  settings,  as
   shown below:

                         .ta 5,10.15,...

   The above command sets tab stops at every 5 positions.  The ".ta"
   command,  is  used  in  conjunction with the ".fc" command, which
   describes the format of the text.






                                - 65 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


        Let's digress a moment.  First of all, the text  has  to  be
   formatted  into  fields.   The "a" in the ".fc" command indicates
   the character being used to delimit the fields.   This  character
   precedes  and follows each field of text.  To further clarify, an
   example is in order.

        Let's assume that you have a file containing  the  following
   information on messages:

            To      From    Timeup  Timedown        Date

   Your file would be formatted as follows:

            .ta 10,20,30,40,50
            .fc /
            .nf
            /ABC//DEF//0900//0950//060978/
            /DEF//GHI//1005//1010//061278/
            /ABC//GHI//1240//1300//061578/

   When displayed, the above file would yield:

          00000000011111111112222222222333333333344444444445
   col.   12345678901234567890123456789012345678901234567890

          ABC      DEF       0900      0950      060978
          DEF      GHI       1005      1010      061278
          ABC      GHI       1240      1300      061578


        Notice that the  system  left-adjusts  the  fields  of  text
   within   the specified tab-stops.  The fields of text can also be
   right-adjusted or centered by using "b," the other  parameter  in
   the "fc" command.


        "b" is referred to  as  the  padding  indicator,  so  called
   because  it  is  used  to indicate on which side of the field the
   extra spaces are to be placed.

                        Example: .fc / ?
                                 /?ABC/

   In this case, the field would be right-adjusted; whereas:

                            /?ABC?/

   would cause this field to be centered



                                - 66 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

        The ".ta" command may be used to cause all text to begin  in
   the  same column.  This is accomplished by specifying only a sin-
   gle value in the ".ta" command, and by  depressing  the  tab  key
   before typing the line of text.  The padding character should not
   be used since it will be interpreted as  text,  and  consequently
   displayed.

   Notes:(1) The default tabs are 9, 17, 25 ... .
         (2) A total of 20 tab stops may be set, and the values  may
             be  separated by spaces, commas, or any other nonmumer-
             ics.
         (3) The delimiter and padding characters may  be  any arbi-
             trarily chosen characters.
         (4) Certain system programs, such as the RAND editor,  will
             remove  tabs  and  replace  them  with  the appropriate
             amount of spaces.

        We've covered a lot of ground. Do you think you're ready for
   the Module Test? If so, look over the objectives for this module.
   Review any material you're uncertain of. Then, scan the  "Command
   Summary"  sheet.  When  you  are  ready, take the module test. It
   begins on the page following the "Command Summary" sheet.






























                                - 67 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


                    _C_o_m_m_a_n_d _S_u_m_m_a_r_y


        _N_r_o_f_f {_o_p_t_i_o_n_s} <_f_i_l_e_n_a_m_e_s>

   Note: The options are -olist, -nN, -s, -T <terminal name>

   .so/usr/lib/tmac.nm (access to "tmac.nm" program) Control charac-
   ters: the period (.) and the apostrophe (')



    1.  .br (Break command)

    2.  .pl (Page length)

    3.  .bp (Begin page)

    4.  .pn (Page numbering)

    5.  .po (Page offset)

    6.  .fi (Fill output lines)

    7.  .nf (No-fill output lines)

    8.  .ad (Adusting output lines)

    9.  .ad c (Text centered)

   10.  .ad r (Text right-adjusted)

   11.  .ad n (Both margins adjusted)

   12.  .na (No adjust)

   13.  .ce n (Center output lines)

   14.  .ls n (Line spacing)

   15.  .sp n (Vertical spacing)

   16.  .ll n (Line length)

   17.  .in n (Automatic indenting)

   18.  .ti n (Temporary indent)

   19.  .de <name> (Define command; defines macro "<name>.")
              <commands/text>

                                - 68 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   20.  .wh n <name> (line trap; invokes macro "<name>.")

   21.  \\$1, \\$2, \\$3,etc (Arguments used with macros. There  may
        be as many as nine with one macro.)

   22.  .ds <name> string (defining a character string)

   23.  .tl '<name>' (Title command)

   24.  .tl '<name>'page%' (Title command with page no.option)

   25.  \\n(mo
        \\n(dy  } Date options
        \\n(yr

   26.  .tr (Character translation)

   27.  .ta n (Tab stop settings. Used with the ".fc" command.)

   28.  .pl (Page length)

   29.  .bp (Break page)

   30.  .pn (Page numbering)

   31.  .po (Page offset)

   32.  .br (Break)

   33.  .fi (Fill output line)

   34.  .nf (No fill output lines)

   35.  .ad c (Adjusting output lines)

   36.  .na (No adjust)

   37.  .ce (Centering output lines)

   38.  .ls (Line spacing)

   39.  .sp (Vertical space)

   40.  .de (Macro definition)

   41.  .in (Indent)

   42.  .ll (Line length)

   43.  \\$n (Argument definition)


                                - 69 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   44.  .ds <name> <string> (Character string definition)

   45.  .ul (Underline a line)

   46.  .tl (Title definition)

   47.  %   (Current page number)

   48.  \\n(mo (Current month)

   49.  \\n(dy (Current date)

   50.  \\n(yr (Current year)

   51.  .tr (Character translation)

   52.  .ta & .fc (Set tabs)



































                                - 70 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


   _M_o_d_u_l_e _I_I _T_e_s_t

   DIRECTIONS: Use only the "Command Summary" sheet  as  an  aid  in
   taking this test.  Minimum passing score is 11 out of 16 correct.



    1.  What command is used to gain access to the nroff program?

    2.  For what purpose in the nroff command used?

    3.  The command:"nroff -o1-10 junk" will:
            a.  display the file, junk, beginning with page 10.
            b.  display the file, junk, ending after page 10.
            c.  display the file, junk, numbering the  first  output
                page as 10.

    4.  Give a brief explanation of the following commands:
            a.   .bp 8
            b.   .pn
            c.   .po 8

    5.  Write the command which will cause a maximum of 40 lines  to
        be placed on each page.

    6.  List 3 commands which will cause the "fill line mode" to  be
        ineffective.
                 a. _______
                 b. _______
                 c. _______


    7.  Write 2 commands used to center output lines, and state  how
        they differ.
                 a. _______ b. ____________
                 Differences: _____________________________________

    8.  Which of the following will cause double spacing:
                 (a) .ls 2
                 (b) .sp 2
                 (c) both

    9.  Briefly explain the following:
                 (a) .de
                 (b) .ds
                 (c) \\$n

   10.  Execution  of   a  macro  is  delayed  until   a   _________
        ___________ or a ______________ is encountered.


                                - 71 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

   11.  A character string "po" has been defined; write the  command
        used to display its text.

   12.  Write the command which causes a maximum of 40 characters to
        be placed on each line.

   13.  Write 2 commands which can be used to prepend  5  spaces  to
        output lines.

   14.  Write the necessary commands to define and execute  a  macro
        which  displays a title containing the current date and page
        number at the top of each page.

   15.  Write a command which will  display  a  slash  each  time  a
        period is encountered in the file.


        Correct your test by the key located on the next  page.   If
        you  miss  more  than 5 questions, please review this module
        before continuing to module III.  Contact your instructor if
        you need additional help.































                                - 72 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


   _A_n_s_w_e_r_s _t_o _m_o_d_u_l_e _I_I _t_e_s_t



    1.  _N_r_o_f_f is the command used to gain access to the  nroff  pro-
        gram.

    2.  The nroff program is used for _f_o_r_m_a_t_t_i_n_g _t_e_x_t.

    3.  The command:  _n_r_o_f_f  -_o_1,_1_0  _j_u_n_k  will  display  the  file,
        "junk", ending after page 10.

    4.
            a.  .bp 8 -- will begin a new page and will  number  the
                new page 8.
            b.  .pn 8 -- will number the first page 8.
            c.  .po 8 -- will prepend 8 spaces to each output line.

    5.  ._p_l _4_0 is the command used to place a maximum of 40 lines on
        each page.

    6.  ._n_f,._b_r, _a_n_d ._s_p will cause the "fill line mode" to be inef-
        fective.

    7.  ._a_d _c _a_n_d ._c_e are used to center output lines. ".ad c"  will
        center  with line filling and ".ce" will center without line
        filling.

    8.  ._l_s _2 will cause double spacing. ".sp 2" will  cause  triple
        spacing since it causes 2 blank lines to be displayed.

    9.
            a.  .de -- defines a macro.
            b.  .ds -- defines a character string.
            c.  \$n -- defines an argument.

   10.  Execution of a macro is delayed until a _m_a_c_r_o _r_e_f_e_r_e_n_c_e or a
        _t_r_a_p is encountered.

   11.  *(_p_o will display the character string, "po."

   12.  ._l_l _4_0 will cause a maximum of 40 characters to be placed on
        a line.

   13.  ._i_n _5 _a_n_d ._p_o _5 will prepend 5 spaces to output lines.

   14.  .de xx
        .tl '\n(mo \n(dy \n(yr''page%'
        ..
        .wh 0 xx

                                - 73 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX

        will define and execute a macro which displays a title  con-
        taining the current date and page number in upper case roman
        at the top of a page.

   15.  ._t_r ./ will cause a slash to be displayed each time a period
        is encountered.














































                                - 74 -
   Unit III                                                Module II







   MP119                                        Introduction to UNIX


                     _M_o_d_u_l_e _I_I_I   _A_d_d_i_t_i_o_n_a_l _f_o_r_m_a_t_t_i_n_g _t_e_c_h_n_i_q_u_e_s


        _O_b_j_e_c_t_i_v_e_s

   After completion of this module, you will be able to:

    1.  Generate headers and footers.

    2.  Prevent extra spaces between words.

    3.  Generate classifications at the top and bottom of each page.

    4.  Underline portions of a line.

    5.  Automatically indent for paragraphs.

    6.  Automatically generate paragraph headings.

    7.  Cause automatic numbering of paragraphs.

    8.  Generate outlines up to three levels.

    9.  Prevent word hyphenation.

   10.  Annotate files.

   11.  Generate a table of contents.























                                - 75 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX


        _I_n_t_r_o_d_u_c_t_i_o_n


        You probably found  the  preceeding  module  somewhat  rough
   going, particularly the sections on generating macros, using line
   traps and the like. Well, relax. You'll find  that  most  of  the
   gory  details  of the material in this module has been taken care
   of for you.

        This module discusses additional formatting techniques which
   are  achieved  by using a set of general purpose macros, referred
   as "NM" macros.

        These macros are used in conjunction with the nroff commands
   to provide an extensive variety of styles for memoranda, letters,
   lists, and other documents.

        The "NM" macros are easy to use and they'll save you consid-
   erable effort.

        In order to use the macro package you must put the following
   special line at the begining of your file:

             .so /usr/lib/tmac.nm

   Yes it's the same line we encountered earlier.  Try  to  remember
   that  without  this line in your file the macros carry no special
   meaning.

        _H_e_a_d_e_r_s


        The "NM"  macros  provide  a  simple  method  of  generating
   headers.   The  first  five lines of each page are made available
   for this purpose.  Let's format five header lines:

                       .ds H1 SNOOPY'S JOURNAL
                       .ds H2 by
                       .ds H3 Charlie Brown
                       .ds H4 and
                       .ds H5 Linus

        The system will automatically center the above five  headers
   on each output page.  Have you noticed that this notation is very
   similar to the notation used to define a character string?  Well,
   there  are  a couple of differences. The header doesn't require a
   reference to its name before being displayed; and,  its  name  is
   preassigned, not arbitrarily choosen.



                                - 76 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

        Any header line may be suppressed  by  simply  omitting  it.
   You  may  also  cause a blank line to be displayed where a header
   would have been by typing:

                            .ds H2 ~

   That's an odd looking character, isn't it?  It's called  a  tilde
   and  it is used to generate one and only one space. Therefore, it
   also can be used to ensure that extra spaces aren't added between
   words. For instance, it could be used to make sure only one space
   is added between "Charlie" and "Brown", as follows:

   Example:             Charlie~Brown

   Remember our earlier discussion of ".tr ~ "?

        Provision is also made for providing left and right  adjust-
   ment  within  the  five  header lines. The commands used for this
   purpose are as follows:

                  .ds Hl heading-left (H1)
                  .ds Hm heading-left (H2)
                  .ds Hn heading-left (H3)
                  .ds Ho heading-left (H4)
                  .ds Hp heading-left (H5)
                  .ds Hr heading-right(H1)
                  .ds Hs heading-right(H2)
                  .ds Ht heading-right(H3)
                  .ds Hu heading-right(H4)
                  .ds Hv heading-right(H5)

        When using left and right adjusted headers keep in mind  the
   fact  that  the  line  on  which  they  appear must be previously
   defined.  This is done by specifing header text or  a  space  (~)
   after  a  commmad  of  the  sort  .ds H1 (for instance .ds H1 ~).
   Header text used in this situation will be centered on the output
   line.   If  you fail to define the line before referencing a left
   or right adjusted header the entire line (including your adjusted
   header) will be suppressed.

        _F_o_o_t_e_r_s


        The system will also display three lines, called footers, at
   the  bottom  of  each  output page. The first footer line, F1, is
   automatically set to produce the current page number and date. To
   get:

                       -1-               November 2, 1979

   at  the  bottom  of  each  page,  do  nothing.  This  display  is

                                - 77 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

   automatically produced by the following macros:

                  .ds F1  - % -
                  .ds Fd  \*(DY

   where \*(DY represents a pre-defined string giving today's  date.
   (You  can  change it if you want.) To supress the entire F1 line,
   both page number and date, type:

                            .ds F1

   To supress the date only, type:

                            .ds Fd

   The second footer line, F2, contains one  field  (text  centered)
   that  is specified by the user. The third footer line accomodates
   left and right adjusted footers. These are produced by  referenc-
   ing  Fl  and Fr after the third footer line has been defined.  As
   with the header lines, this line is defined by  specifing  footer
   text (which is centered) or a space (#).

        _C_l_a_s_s_i_f_i_c_a_t_i_o_n


        Classifications may be formatted to appear automatically  at
   the  top  and at the bottom of each page by using the 'CL' macro.
   Here is an example of how the CL macro would appear.

                       .ds CL Super Hush Hush

   This will produce "Super Hush Hush" before the first  header  and
   after the last footer.

   Note:  Headers,  footers,  and  classifications  may   be   reset
         throughout the file. A later header, footer, or classifica-
         tion suppresses the information in an earlier one.

   Do you think you've mastered  what  we've  just  covered?   Let's
   check your understanding with the following exercise.












                                - 78 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX


        _E_X_E_R_C_I_S_E_S



    1.  Set headers in one of your files such that the current  date
        appears  left-adjusted  and  the current page number appears
        right-adjusted on one line, your name appears on a  separate
        line,  and  your  organization and phone number appears on a
        third line.

    2.  Set footers such that the page number does not appear and  a
        retention date, Jan. 1980, appears on the left of the page.

    3.  Combine #1 and #2. Also place "UNCLASSIFIED" at the top  and
        bottom of each page.

        _U_n_d_e_r_l_i_n_i_n_g  (._I)


        In your study of nroff, you learned how to underline a  sin-
   gle line or several lines; however, the need may arise where only
   a word or several words require underlining.  The "NM" macro (.I)
   affords  you  this option.  To underline a single word, you would
   specify:

                            .I a-word

   Or to underline several words, you would specify:

                       .I "A few words"
                              or
                       .I A few words

   The results yielded will be:

                          _a-_w_o_r_d
                          _A _f_e_w _w_o_r_d_s
                          _A


        The system ignores all text following the occurrence of a space;
   therefore, double quote marks or the tilde must be used when more
   than a single word is to be underlined.

        Complete lines may be also underlined without specifying the number
   of lines to be underlined by using the following notation:

                    .I
                    <lines of text>
                    .R

                                - 79 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

   Example:
                    .I
                    I am a line of text.
                    The system is going to
                    underline me because I'm
                    preceeded by the macro "I".
                    .R

   Where all lines of text placed between .I and .R will  be  under-
   lined, such as:

                   _I _a_m _a _l_i_n_e _o_f _t_e_x_t.
                   _T_h_e _s_y_s_t_e_m _i_s _g_o_i_n_g _t_o
                   _u_n_d_e_r_l_i_n_e _m_e _b_e_c_a_u_s_e _I'_m
                   _p_r_e_c_e_e_d_e_d _b_y _t_h_e _m_a_c_r_o "_I".

   The ".I" means italic type; the ".R" means Roman type. If you had
   used  troff  and  the  phototypesetter you would have had italics
   instead of underlining.  A word/words embedded within a  line  of
   text is underlined in the following manner:

                    <beginning of line>
                    .I "text to be underlined"
                    <end of line>

   Example:         Now is the time for
                    .I "all good men"
                    to come to the aid of their party.

   would appear as:

                   Now is the time for _a_l_l _g_o_o_d _m_e_n to come  to  the
                   aid of their party.

   Note: The "Fill output line" mode must be turned on.

        _P_a_r_a_g_r_a_p_h _F_o_r_m_a_t_i_o_n (._P_P)


        Paragraphs may be formed simply by typing

                  .PP [indent] [line spacing]

   In this case, "indent" denotes the number of spaces to indent the
   first  line of the paragraph. Also, "line spacing" represents the
   number of lines (minus one) to skip before  beginning  the  para-
   graph.  Below is an example of the "paragraph formation" command.

                            .PP 5 3
                            <text>


                                - 80 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

   This causes the first line of the paragraph to  be  automatically
   indented  by  5  spaces,  and 2 blank lines to be left before the
   paragraph. To form block style pargraphs; that is, double spacing
   between paragraphs and no indention, specify:

                            .PP 0 2

   Note: Once the parameters have been set in the  first  "PP"  com-
         mand,  subsequent  commands  need  only  specify  parameter
         values when the values are to be changed.


        _P_a_r_a_g_r_a_p_h _H_e_a_d_i_n_g_s (._P_H)


        The "NM" macros also provide a macro  which  allows  you  to
   place a heading over a paragraph.  The form of the macro is

                       .PH [heading]

   where "heading" is the value to appear as  the  heading  for  the
   paragraph.   One  blank  line will be placed before and after the
   heading.

               Example:    <text>
                           .PH "NM MACROS"
                           <text>

   would yield

                           <text>

                           NM MACROS

                           <text>

   Notice: Automatic spacing and the first line of text do not occur
   on the same line as the heading.

        Okay, let's expand the .PH macro  to  determine  what  other
   neat  options  are  available  to  you.  Here is a sample of that
   expansion.

             .PH [heading] [indent] [ls to heading]
             [ls heading to text]
   The ls to heading and the ls to text are the number of lines plus
   one.





                                - 81 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

        For starters, the above  options  can  be  used  to  specify
   whether  or not the heading is to be indented, and to specify the
   number of blank lines to be left before and  after  the  heading.
   Here is an example.

                     .PH NM MACROS 5 4

   This would cause the heading to be indented by 5 spaces, 3  blank
   lines  to  be  placed before the heading and one blank line after
   it.  What determined that one blank line would follow the   head-
   ing?  Answer in the space provided.




        Is your answer, "the default (or predefined)  value  of  the
   4th option?" That's it exactly.  Any or all of the options may be
   omitted. However, the system will supply a value for the  omitted
   options before executing the macro.  The default values are:

                       .PH "" 0 2 2

   Notes:(1) The "2's" denote the number of  lines,  minus  one,  to
         skip before and after the heading, respectively.
         (2) If an omitted option is  followed  by  another  option,
         then  you must specify the default value or 0.  Suppose you
         want to change the value of the third option  and  not  the
         second. Then you would specify

                          .PH heading 0 5


        Let's further explore the .PH macro to include still another
   option, as follows:

                       [ls to text] [font]

   The "font" allows you to underline the paragraph  heading.   This
   may  be achieved by specifying either a "2" or a "3" as the font.
   The default value is 0.

        The last PH macro option (and perhaps  the  most  frequently
   used) allows automatically number paragraphs.  The option is

                       [assigned format]

   where "Assigned format" indicates that the  paragraph  is  to  be
   numbered according to the specified format.




                                - 82 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

        Following are several format options which can be  specified
   to give different types of numbering:

   _S_p_e_c_i_f_y                     _T_o _G_e_t

      1                         1,2,3,4,...
      i                         i,ii,iii,iv,...
      I                         I,II,III,IV,...
      a                         a,b,c,d,...
      A                         A,B,C,D,...

   Note:  This option and the previously discussed options  need  to
   be  specified  only  on  the first PH line, subsequent paragraphs
   need only to be preceded by "PH."

                Example:  .PH "" 0 2 2 0 I
                          <text>
                          .PH
                          <text>
                          .PH
                          <text>

   With this combination of commands the result would be:

                          I

                          <text>

                          II

                          <text>

                          III

                          <text>


        Observe that the number was placed on a separate line  above
   the  paragraph.   How do you suggest the .PH macro be modified to
   achieve numbering on the same line? Answer in the space provided.




   What's your answer? Is it change the third option  to  0?  That's
   exactly  what  you would do. Also, if all you're interested in is
   numbering paragraphs, the macro may be formed as follows:

                     .PH "" 0 0 0 0 I



                                - 83 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

        Now let's take a look at the .PH macro in its entirety.

                  .PH "NM MACROS" 0 5 3 2 i

   What will be the results of the  above  command?  Answer  in  the
   space below.


        The above command establishes "NM  MACROS"  as  a  paragraph
   heading.   The  heading is underlined and numbered with the Roman
   numeral i. It will not be indented, four blank lines will preceed
   it, and two blank lines will follow.

        If your analysis is contrary to  the  above,  please  review
   this section.

        _O_u_t_l_i_n_e _S_t_y_l_e _P_a_r_a_g_r_a_p_h _H_e_a_d_i_n_g_s


        There is an alternative to the type  of  paragraph  headings
   discussed  in the preceeding section. This is a system of outline
   style headings of the following form:

                  1. I Must Be Crazy
                  2. To Be Taking This Course

   These headings are obtained by typing in the following commands:

                  .P1 I~Must~Be~Crazy
                  .P1 To~Be~Taking~This~Course

   Successive uses of  the  .P1  macro  will  cause  an  incremental
   increase  in  the  numbers  assigned  to  the paragraph headings.
   Notice that tildes must be used to delimit blank  spaces  in  the
   headings.

        You might be thinking that there must  be  more  to  outline
   style  headings  than  this. If you are, you're absolutely right.
   Additional heading levels can be obtained by using the other com-
   mands in the series .P1,P2.....P6.  Things will get a little more
   complicated at this point, so hang in  there.   Following  a  .P1
   command with a .P2 command ,for example:

                  .P1 I~Must~Be~Crazy
                  .P2 Wildly~Crazy
                  .P2 Truly~Insane
                  .P1 To~Be~Taking~This~Course

   will produce this sort of heading structure:
                  1.  I Must Be Crazy
                  1.1.  Wildly Crazy

                                - 84 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

                  1.2.  Truly Insane
                  2.  To Be Taking This Course

   Can you guess what the addition of a .P3 will do to  our  heading
   structure?  Well, let's say we put ".P3 Right~Off~The~Wall" after
   the last .P2 entry in the above example. What do  you  think  the
   resulting  heading structure will look like? Place your answer in
   the space provided.



   You're absolutely right if your answer matches the following one:

                  1.  I Must Be Crazy
                  1.1.   Wildly Crazy
                  1.2    Truly Insane
                  1.2.1.   Right Off the Wall
                  2.   To Be Taking This Course

        Outline style headings certainly seem to be a  useful  tool,
   don't  they?  Well, you have'nt seen anything yet. Wait until you
   see how they're used with the table of contents macro.

        _T_a_b_l_e _o_f _C_o_n_t_e_n_t_s


        The table of contents macro (.TC)  is  used  in  conjunction
   with  outline  style  headings (.P1,.P2......P6). The numbers and
   headers of all paragraphs  using  the  outline  style  macro  are
   "remembered" so that a table of contents can be "recalled" at the
   conclusion of the document.  Retrieving  the  table  of  contents
   could'nt be more simple, you simply type:

                            .TC

   at the end of the file. A  table  of  contents  will  be  printed
   starting on a new page.  The table of contents is already set up,
   with the heading "Table of Contents," and pages numbered begining
   with i.

   Note: Any heading associated with  the  .PH  macro  will  not  be
         included in the table of contents.

        _F_o_r_m_i_n_g _O_u_t_l_i_n_e_s


        Sooner or later, you will be given some text to  place  into
   an  outline  form.  Quite a task isn't it, with all the numbering
   and indenting, etc?



                                - 85 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

        Well, hang in there, you've been rescued again.  Macros  are
   available which automatically number and indent text to form out-
   lines up to 3 levels.

        Suppose you want to enumerate a list of items such as:

                          1. fruits

                          2. meats

                          3. vegetables

   Then in your file, you would type:

                          .L1
                          fruits
                          .L1
                          meats
                          .L1
                          vegetables
                          .E1

   ".L1"  places the text that follows on level 1.  "E1" denotes the
   end  of  the level 1 list.  The counter is reset, thereby causing
   the next occurrence of the  ".L1" macro to  begin  the  numbering
   again at 1.

   Note: The text isn't limited to  a  single  word.  It  may  be  a
         phrase, a group of sentences.

        Now let's expand the outline to include items on the  second
   level.  To form the following outline

                    1.  fruits
                            a.  apples
                            b.  oranges
                            c.  plums
                    2.  meats
                    3.  vegetables













                                - 86 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

   the text in your file would appear as

                           .L1
                           fruits
                           .L2
                           apples
                           .L2
                           oranges
                           .L2
                           plums
                           .E2
                           .L1
                           meats
                           .L1
                           vegetables
                           .E1

   Observe that the macro ".L2" places the text that follows on  the
   second  level,  and  that  the macro ".E2" ends the level 2 list.
   ".E2" also resets the counter for the second level.

        What do you think are the macros used  in  establishing  the
   third level in an outline?  Answer in the space provided.



   You are right if you answered ".L3" and ".E3."


        Are you ready to try one? Okay, write what you would type in
   your file to obtain the following:

              1.  fruits
                      a.  apples
                              o+   delicious
                              o+   golden
                      b.  oranges
                      c.  plums

              2.  meats

              3.  vegetables
                      a.  peas
                      b.  potatoes








                                - 87 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

   Notice the strange little symbol on the third level. It's  called
   a bullet.  This is the symbol used to number items placed on this
   level.

        Now compare your solution with the  solution  that  follows,
   then try it on the terminal.

                             .L1
                             fruits
                             .L2
                             apples
                             .L3
                             delicious
                             .L3
                             golden
                             .E3
                             .L2
                             oranges
                             .L2
                             plums
                             .E2
                             .L1
                             meats
                             .L1
                             vegetables
                             .L2
                             peas
                             .L2
                             potatoes
                             .E2
                             .E1


        _M_o_r_e _o_n _O_u_t_l_i_n_e_s


        The macros in the previous section aren't quite so rigid  as
   they  appear  to be. Actually you have a great deal of control in
   forming your outlines.  Let's take a look at  the  options  which
   may be specified in the macros used in forming outlines.

                  .L1 [indent] [line spacing] [assigned
                  format] [left string] [right string]

   The value in the "indent" option indicates the number  of  spaces
   to  place  before  the  numbered  item.  The "line spacing" value
   denotes the number of blank lines to place before the item.   The
   "assigned  format"  has the same meaning previously discussed. It
   determines the type of numbering to be used. The next two options
   are  used  to  place characters before and after the number.  You


                                - 88 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

   can do such things as command

                       .L1  5 2 A {  }
                       fruits

   would yield



                       {A}  fruits

   Notes:(1) Use of the "tilde" insures exact  spacing  between  the
             number and the text item.
         (2) The default options are:
                       .L1 8 1 1  "" .

         (3) The options for the "L2" macro are the same as for  the
             "L1" macro, except that the assigned format is "A".

        There are actually six  of  these  macros:  .L1,.L2,.L3,.L4,
   .L5, and .L6 and corresponding ending macros (i.e. .E1,.E2,
   .E3,.E4,.E5 and .E6). The defaults values for these macros are as
   follows:


       1.
               a.
                       o+
                              []
                                       I.
                                               A.

   Notes:(1) These six macros may be used in other  contexts.   That
             is,  they  may  be used to number any line of text, not
             just items in an outline. You do not  have  to  specify
             one  just  because  the  other  has been specified. For
             example, L2 may be specified without specifying L1  and
             vice versa.
         (2) L1 and L2 may be coded such that the default  numbering
             is over-ridden in either or both.
         (3) All specified options remain in effect unless  respeci-
             fied.

   Example:                 .L1 5 2 i [ ]
                             <text>
                             .L1
                             <text>
   would yield:
                             [i] <text>
                             [ii] <text>


                                - 89 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX


        _B_u_l_l_e_t _M_a_r_k_e_d _I_t_e_m_s


        Lines of text may be bullet marked by using

                         .BU [indent]

   where "indent" is the number of blanks placed  in  front  of  the
   bullet.  The default is 8.

        If you type, for example:

                       NM MACROS are used for:
                       .BU
                       Creating headers and footers
                       .BU
                       forming paragraph headings
                       .BU
                       Underlining
                       .in 0


   you will get:

   NM MACROS are used for:

           o+  Creating headers and footers

           o+  Forming paragraph headings

           o+  Underlining

        CAUTION: Following execution of the bullet macro, the system
   continues  to  indent  any subsequent text.  One of the following
   (.PH,.PP,.in) can be issued to rectify this situation.  Note that
   .L3 has the same effect as .BU and is preferred.

        _W_o_r_d _H_y_p_h_e_n_a_t_i_o_n


        This unique feature allows you to control  word  hyphenation
   when  displaying  your files. That is, you can dictate whether or
   not a word is to be hyphenated.  To prevent word hyphenation sim-
   ply  place a caret or the circumflex adjacent to the first letter
   of the word.  Suppose you had specified a line length of  50  and
   you type the word "communication" beginning in column 45:





                                - 90 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

             columns
            11111111112222222222333333333344444444445
   12345678901234567890123456789012345678901234567890
                                            any communication

   The system will display:

             columns
            11111111112222222222333333333344444444445
   12345678901234567890123456789012345678901234567890
                                              any com-
   munication

   as opposed to:
                                          any
   communication

   if you had typed:

                 ^communication
   in column 45.

        _A_n_n_o_t_a_t_e _F_i_l_e_s


        Comment lines are used to describe the contents  or  purpose
   of a file, and may be incorporated  within a file without affect-
   ing the output.  Consequently,  a  file  may  be  documented  and
   created  simultaneously.  Not only do comment lines enhance docu-
   mentation, but they facilitate  determining  the  contents  of  a
   file, and should be used quite liberally throughout the file.

                  ' These are comment lines.  Lines
                  ' which begin in column 1 with either
                  . a single quote, a period, or
                  . a backlash and quote mark.
                 \" Don't leave a space after the comment
                 \" symbol or the comment will appear in output.

   Note: Comments are ignored by Nroff, and will  not  appear  as  a
         part of the output.











                                - 91 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX


        _E_x_e_r_c_i_s_e


        Create the following file which is an  outline  catagorizing
   the different types of computer languages.  Use at least one com-
   ment line.


7      (I)  machine language
              (A)  coded in numerics
              (B)  languages
                   o+   Burroughs 6700
                   o+   Univac 494
                   o+   CDC 7600
7     (II)  Assembly language
              (A)  Coded in mnemonics
              (B)  languages
                   o+   PDP-11
                   o+   IBM 370
                   o+   Univac 1108
7    (III)  Compiler languages
              (A)  Coded in English-like statements
              (B)  languages
                   o+   Fortran
                   o+   cobol
                   o+   PL/I


   ****Congratulations, you've  completed  another  module.   Please
       review the module before taking the module III test.
























                                - 92 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX


                        _M_o_d_u_l_e _I_I_I _T_e_s_t



   (1)  Headers can be generated on each output page  by  using  the
        ___________ Macros.

   (2)  Footers can be generated on each output page  by  using  the
        _____________ Macros.

   (3)  Headers and footers are automatically
           (A)  left-adjusted.
           (B)  right-adjusted.
           (C)  centered.

   (4)  The "CL" macro causes the  specified  classification  to  be
        displayed
           (A)  at the top of the page.
           (B)  at the bottom of each page.
           (C)  both (A) and (B).

   (5)  Write the  necessary  commands  to  generate  the  following
        headers:
                      SECRET
   7/28/78                               E53MEMO

   (6)  Write the command to begin a paragraph having the first line
        indented by 5 spaces.

   (7)  Write the command to number paragraphs in a file with  capi-
        tal Roman numerals.

   (8)  Write the command to format the word "heading" as an  under-
        lined paragraph heading.

   (9)  Analyze the following:

                  (a)  .L1 "" 0 a [ ]
                  (b)  .L2
                  (c)  .E3
                  (d)  .BU










                                - 93 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

   (10)  What will the following produce?
                  .PH " aaaaaaa" 0 1 0 0
                  .L1 "" 1 A
                  bbbbbbb
                  .L2 "" 1 1
                  ccccccc
                  .L3
                  ddddddd
                  .L2
                  ccccccc
                  .L1
                  bbbbbbb

   (11)  Rewrite the following text such that the first 2 groups and
        the last 2 groups are underlined.

             aaaa aaaaa bbb bbbbbb
             cc cccc ddd dddddd



       (1)  What commands would you have to type in to get the  fol-
            lowing:

            1.   This UNIX Manual
            1.1.   Sure Does Make Pleasant Reading

   ****Compare your  answers  to  the  following  answers.   If  you
   answered  four  or  more  incorrectly,  please review this module
   before proceeding to the Unit III proficiency test.






















                                - 94 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX


        _A_n_s_w_e_r_s _t_o _m_o_d_u_l_e _I_I_I _t_e_s_t



   (1)  Headers can be generated on each output page  by  using  the
        _H_e_a_d_e_r (_H_1,_H_2,_H_3,_H_r,_H_l)  macros.

   (2)  Footers can be generated on each output page  by  using  the
        _F_o_o_t_e_r (_F_1,_F_2,_F_3,_F_r,_F_l)  macros.

   (3)  _C  headers and footers are automatically centered.

   (4)  _C  The "CL" macro causes the specified classification to  be
        displayed at the top and at the bottom of each page.

   (5)
                  .ds H1
                  .ds Hl 7/28/78
                  .ds Hr E53MEMO
                  .ds CL SECRET

        will generate the following headers:

                      SECRET
   7/28/78                               E53MEMO


   (6)  ._P_P _5 will begin a paragraph indenting the first line  by  5
        spaces.

   (7)  ._P_H "" _0 _0 _0 _I will number paragraphs in a file with capital
        roman numerals.

   (8)  ._P_H  will format the word "heading" as an  underlined  para-
        graph heading.

   (9)
           (A)  ._L_1 " _O _a [ ] will place the text  that  follows  on
                the  first  level,  and  the numbering will be lower
                case  alphabets  enclosed  within   brackets.    The
                default value of 8 is used for the indent parameter,
                and no blank lines will precede the text.

           (B)  ._L_2 will place the text that follows on  the  second
                level.  All  default  options  will be used, thereby
                causing the numbering  to  be  lower-case  alphabets
                followed by a period and two spaces, indent value is
                8, and one blank line is placed before the text.



                                - 95 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX

           (C)  ._E_3 is used to determine the third level list of  an
                outline.

           (D)  ._B_U is used to bullet mark and to  indent  lines  of
                text by 10 spaces.


   (10)

   aaaaaaa
   (A)  bbbbbbb
           (1)  ccccccc
                    o+   ddddddd
           (2)  ccccccc
   (B)  bbbbbbb

   (11)

         .I "aaaa aaaaaa"
         bbb bbbbbb
         cc cccc
         .I "ddd dddddd"

   (12)

   The necessary commands:



   _1.  _T_h_i_s~_U_N_I_X~_M_a_n_u_a_l


   and

   _1._1.  _S_u_r_e~_D_o_e_s~_M_a_k_e~_P_l_e_a_s_a_n_t~_R_e_a_d_i_n_g

















                                - 96 -
   Unit III                                               Module III







   MP119                                        Introduction to UNIX


        _S_u_m_m_a_r_y _o_f _N_M _M_A_C_R_O_S



   (1)  Headers
        .ds Hl
        .ds Hr
        .ds H1
        .ds H2
        .ds H3

   (2)  Footers
        .ds Fl
        .ds Fr
        .ds F1
        .ds F2
        .ds F3

   (3)  .ds CL <classification>

   (4)  .PP [indent][lines spacing]

   (5)  .PH  [heading][indent][ls  to  heading]   [ls   heading   to
        text][font] [assigned format]

   (6)  Outlines
        .L1/.L2 [indent][linespacing]
        [assigned format][right string]
        [left string]

        .L3 [indent][line spacing]

   (7)  .I <initiate underlining>

   (8)  .R <terminate underlining>

   (9)  .BU <bullet>

   (10)  period/appostrophe         comments


   ****Just think!  You've completed another milestone in your  stu-
       dies;  now  prepare  to take the Unit III proficiency test by
       reviewing.  If you have any questions,  please  contact  your
       instructor.   You  are given 60 minutes to complete the test,
       and may use the command summary sheets following each  module
       as a reference.




                                - 97 -
   Unit III                                          Commands & Test







   MP119                                        Introduction to UNIX


        _U_n_i_t _I_I_I _P_r_o_f_i_c_i_e_n_c_y _T_e_s_t



    (1)  List the commands to do the following:
            (a)  gain access to the Unix Text Editor.
            (b)  create a file called "junk" containing: I am a junk
                 file.  I'm used for testing commands.
            (c)  display the file.
            (d)  leave the editor.

    (2)  Write the ed command to display the text three lines before
         the current line.

    (3)  What is the ed command used to determine the current line?

    (4)  Write the ed command to delete  all  dollar  signs  from  a
         file.

    (5)  Briefly explain the following ed commands:
            (a)     i
            (b)     c
            (c)     m

    (6)  The ed command "3a" will:
            (a)  append 3 lines of text to the buffer.
            (b)  append text following the 3rd line of text  in  the
                 buffer
            (c)  append the text in the buffer to itself 3 times.

    (7)  The ed command "250w junk" will:
            (a)  create the file junk consisting of 250 lines of the
                 current file.
            (b)  create the file junk consisting of line 250 of  the
                 current file.
            (c)  Concatenate line 250 of the  current  file  to  the
                 contents of junk.

    (8)  The ed command "e junk" will:
            (a)  read the file, junk, into the buffer destroying the
                 current contents.
            (b)  read the file, junk, into the buffer  appending  it
                 to the current contents.
            (c)  erase the file, junk, from the buffer.

    (9)  What will be the result of the following ed command?
             s/.*/(&)/p

         The following questions refer to nroff:


                                - 98 -
   Unit III                                          Commands & Test







   MP119                                        Introduction to UNIX

   (10)  Analyze the following UNIX command:

         nroff -s -o8-20 junk

   (11)  The  "Nroff" program is used for:
            (a)  modifying files.
            (b)  creating files.
            (c)  formating files.

   (12)  The nroff command ".pn 8" will:
            (a)  eject a new page and will number the new page 8.
            (b)  number the first page 8.
            (c)  prepend 8 spaces to each output line.

   (13)  The nroff command ".ul" will:
            (a)  underline the current line.
            (b)  underline the next line.
            (c)  continue to  underline  text  until  a  command  is
                 encountered which terminates the underlining.

   (14)  Write the necessary nroff commands to  define  and  display
         the  character  string  "CS"  which  contains the following
         text:
                  This is a character String

   (15)  Write the necessary nroff commands to define and execute an
         nroff macro "mo" which displays the following:

              user's name                   user's group

           Note: the user's name and group is passed  to  the  macro
                 via arguments.


   (16)  The nroff command ".ti 10" will:

            (a)  indent the next 10 lines of text.
            (b)  indent the next line of text by 10 spaces.
            (c)  indent all subsequent lines of text by 10 spaces.

   (17)  Contrast the following:

            (a)  ".br" and ".sp" to begin a new line.
            (b)  ".ls" and ".sp" to obtain vertical spacing.
            (c)  ".ad" and ".ce" to center lines.

   (18)  Briefly explain the following nroff commands:

            (a)  (a) .ta 10 20 30 40
            (b)  (b) .tr aA


                                - 99 -
   Unit III                                          Commands & Test







   MP119                                        Introduction to UNIX

   (19)  What will the following yield?

        .de xx
        .tl  '''\n(mo/\n(dy/\n(yr page %'
        ..
        .wh 0 xx

   (20)  Write the series of nroff commands that  will  produce  the
         following paragraph heading structure:

                       1.    Book I
                       1.1.    Chapter I
                       1.1.1.    Verse I

   (21)  What will the following produce?

        .ds H1 ~
        .ds Hr page %
        .ds Hl 07/28/80
        .ds H2 John Johnson
        .ds H3 E53    x8007

   (22)  What will the following produce?

        .ds CL unclassified
        .ds F1
        .ds F3 ~
        .ds Fl Jan. 1980

   (23)  What is the difference between  using  ".I"  and  "ul"  for
         underlining?

   (24)  Briefly explain the following:

            (a)  .PP 5
            (b)  .PH "NM MACROS" 0 2 2 2

   (25)  Write what you would type to produce the following:

     I.  AAAAAA
            (A)  BBBBBB
            (B)  CCCCCC
    II.  DDDDDD
            (A)  EEEEEE
                     o+   FFFFFF
                     o+   GGGGGG


   ****Please contact your instructor to have your  paper  corrected
       before continuing to Unit IV.


                                - 100 -
   Unit III                                          Commands & Test







   MP119                                        Introduction to UNIX


                    _U_n_i_t _I_I_I _C_r_i_t_i_q_u_e _S_h_e_e_t

   DON'T FORGET US!!!  PLEASE TAKE A FEW MINUTES  TO  COMPLETE  THIS
   SHEET.



    1.  It took me approximately  ---------------- hours to complete
        this unit.

    2.  How much experience  did  you  have  before  beginning  this
        course?
           (A)  Plenty.
           (B)  Some, but not much.
           (C)  None.

    3.  Was the material difficult?
           (A)  Too hard.
           (B)  Hard, but not impossible.
           (C)  About right.
           (D)  Easy.
           (E)  Too easy.

    4.  How did you like it?
           (A)  It was fun.
           (B)  It was somewhat enjoyable.
           (C)  It was tolerable.
           (D)

    5.  What did you think of  each  module;  was  the  presentation
        confusing?
        ModuleI - yes ________    no ________
        If yes, where?______________________________________________
        ____________________________________________________________
        ____________________________________________________________
        ____________________________________________________________

        Module II - yes ________    no ________
        If yes, where?______________________________________________
        ____________________________________________________________
        ____________________________________________________________
        ____________________________________________________________

        Module III - yes ________    no ________
        If yes, where?______________________________________________
        ____________________________________________________________
        ____________________________________________________________
        ____________________________________________________________



                                - 101 -
   Unit III                                          Commands & Test







   MP119                                        Introduction to UNIX

        Module IV - yes ________    no ________
        If yes, where?______________________________________________
        ____________________________________________________________
        ____________________________________________________________
        ____________________________________________________________

    6.  Do any sections require more explanation?
        yes________        no__________
        If yes, please help by listing them.
        ____________________________________________________________
        ____________________________________________________________
        ____________________________________________________________

    7.  Were any topics too wordy? ___________
        (Please list them.)
        ____________________________________________________________
        ____________________________________________________________
        ____________________________________________________________

    8.  Were the objectives clearly stated?___________
        (Please let us know which ones that aren't.)
        ____________________________________________________________
        ____________________________________________________________
        ____________________________________________________________




























                                - 102 -
   Unit III                                          Commands & Test




