home *** CD-ROM | disk | FTP | other *** search
/ Nebula / nebula.bin / Documents / Others / UnixCourse / IntermedUnix.txt < prev    next >
Text File  |  1992-04-27  |  355KB  |  6,908 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.                                  UNIX for Intermediate Users
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.                             Developed by:
  37.  
  38.                                    User Liaison Section, D-7131
  39.                             [Name and numbers removed at author's request]
  40.  
  41.  
  42.  
  43.                             Revision Date:
  44.  
  45.                                       TABLE OF CONTENTS
  46.  
  47.  
  48. I.  INTRODUCTION........................................................................ ii
  49.        A.  Audience..................................................................... ii
  50.        B.  Course Objectives............................................................ ii
  51.        C.  Course Handout Conventions...................................................iii
  52.  
  53. 1.  THE FILE CALLED .profile AND PROCESSES..............................................  1
  54.        1.1  HOME........................................................................  1
  55.        1.2  PATH........................................................................  2
  56.        1.3  INGRES Environment Variables................................................  2
  57.        1.4  ING_HOME....................................................................  3
  58.        1.5  TERM_INGRES.................................................................  3
  59.        1.6  ING_EDIT....................................................................  3
  60.        1.7  Processes...................................................................  4
  61.        1.8  Executing a Command.........................................................  4
  62.        1.9  Process Identification......................................................  5
  63.        1.10  Interrupt Handling.........................................................  7
  64.  
  65. 2. COMPILING "C" PROGRAMS............................................................... 10
  66.        2.1  "C": Sample Program with a Main and Two Functions
  67.               in One        ............................................................ 10
  68.        2.2  "C": Compiling a Program.................................................... 12
  69.        2.3  "C": Renaming the Executable Module......................................... 13
  70.        2.4  "C": Giving a Name to the Output File....................................... 14
  71.        2.5  "C": Producing an Assembly Listing.......................................... 15
  72.        2.6  "C": Main and Two Functions in Three Separate
  73.               Source Files.............................................................. 16
  74.        2.7  "C": Compiling but Not Producing an Executable
  75.               Module.................................................................... 17
  76.  
  77. 3.  COMPILING FORTRAN  PROGRAMS......................................................... 18
  78.        3.1  FORTRAN: Sample Program a Main and Two
  79.               Subroutines............................................................... 18
  80.        3.2  FORTRAN: Compiling a Program................................................ 19
  81.        3.3  FORTRAN: Renaming the Executable Module..................................... 20
  82.        3.4  FORTRAN: Giving a Name to the Output File................................... 21
  83.        3.5  FORTRAN: Producing an Assembly Listing...................................... 22
  84.        3.6  FORTRAN: Main and Two Subroutines in Three
  85.               Separate Source              Files........................................ 23
  86.        3.7  FORTRAN: Compiling But Not Producing an Executable
  87.               Module.................................................................... 24
  88.        3.8  FORTRAN: Compiling Object Files to Produce an
  89.               Executable                   Module....................................... 25
  90.  
  91. 4.  COMPILING COBOL PROGRAMS............................................................ 26
  92.        4.1  COBOL: Sample Program with a Main and Two
  93.               Subroutines............................................................... 26
  94.        4.2  COBOL: Compiling a Program.................................................. 27
  95.        4.3  COBOL: Running a Program.................................................... 28
  96.        Workshop 2-4..................................................................... 30
  97.  
  98. 5.  UNIX TOOLS.......................................................................... 34
  99.        5.1  The make Utility............................................................ 34
  100. p: A Pattern Matching Filter............................................................ 37
  101.               5.2.1  More on Regular Expressions........................................ 38
  102.               5.2.2  Closure............................................................ 42
  103.               5.2.3  Some Nice grep Options             ................................ 43
  104.               5.2.4  Summary of Regular Expression Characters........................... 44
  105.        5.3  sed: Edit a File to Standard Output......................................... 45
  106.        5.4  awk: A Pattern Matching Programming Language................................ 49
  107.        5.5  sort: Sort a File........................................................... 53
  108.        5.6  Archiver and Library Maintainer............................................. 56
  109.        5.7  Creating an Archive File with Object Modules................................ 57
  110.        5.8  Verifying the Contents of the Archive File.................................. 57
  111.        5.9  Removing Duplicate Object Files............................................. 58
  112.        5.10  Compiling Main and Archive Files........................................... 58
  113.        Workshop 5....................................................................... 59
  114.  
  115. 6.  UNIX UTILITIES PART I - DISPLAY AND MANIPULATE FILES................................ 63
  116.  
  117. 7.  UNIX UTILITIES PART II - DISPLAY AND ALTER STAUTS................................... 73
  118.  
  119. 8.  UNIX UTILITIES PART III - MISCELLANEOUS............................................. 85
  120.  
  121. 9.  ADVANCED FEATURES OF FTP............................................................ 90
  122.        9.1  Initializing FTP on UMAX.................................................... 91
  123.        9.2  Multiple File Transfers..................................................... 92
  124.        9.3  Auto Login Feature.......................................................... 93
  125.        9.4  Macros...................................................................... 95
  126.        9.5  Filename Translation........................................................ 96
  127.        9.6  Aborting Transfers.......................................................... 97
  128.        9.7  More Remote Computer Commands............................................... 98
  129.        Workshop 10...................................................................... 99
  130.  
  131. APPENDIX A - sh.........................................................................101
  132.  
  133. APPENDIX B - ftp........................................................................116
  134.  
  135. APPENDIX C - C Compiler.................................................................128
  136.  
  137. APPENDIX D - FORTRAN Compiler...........................................................137
  138.  
  139. APPENDIX E - lint.......................................................................147
  140.  
  141. APPENDIX F - cb.........................................................................151
  142.  
  143. APPENDIX G - ar.........................................................................152
  144.  
  145. INDEX...................................................................................157
  146.  
  147. I.  INTRODUCTION
  148.  
  149.  
  150. A.  Audience
  151.  
  152.  
  153. This course is for individuals who need to use utilities and
  154. advanced features of the UNIX operating system.
  155.  
  156.  
  157.  
  158. B.  Course Objectives
  159.  
  160.  
  161. Upon successful completion of this course the student will be
  162. able to:
  163.  
  164.        1.     Compile C, FORTRAN, and COBOL programs.
  165.  
  166.        2.     Create processes to run in the background
  167.  
  168.        3.     Use advanced features of FTP such as: multiple file
  169.               transfers, auto logins, macros, globbing, filename
  170.               translation, aborting transfers, and other remote
  171.               computer commands.
  172.  
  173.        4.     Use UNIX utility programs such as grep, sed, awk, sort,
  174.               and others.
  175.  
  176.        5.     Use the make utility.
  177.  
  178.        6.     Understand processes, including structure, executing a
  179.               command, process identification, exit status, plus .
  180.               (dot) and exec processing.
  181. C.  Course Handout Conventions
  182.  
  183.  
  184. There are several conventions used in this handout for
  185. consistency and easier interpretation:
  186.  
  187.  
  188.        1.     Samples of actual terminal sessions are single-lined
  189.               boxed.
  190.  
  191.  
  192.        2.     User entries are shown in bold print and are
  193.               underlined.
  194.  
  195.               exit
  196.  
  197.  
  198.        3.     All keyboard functions in the text will be bold.
  199.  
  200.               (Ret)                       Backspace
  201.               Tab                         Ctrl-F6
  202.               Print (Shift-F7)            Go to DOS (1)
  203.  
  204.               NOTE:         (Ret) indicates the Return or Enter key
  205.                             located above the right Shift key.
  206.  
  207.  
  208.        4.     Examples of user entries not showing the computer's
  209.               response are in dotted-lined boxes.
  210.  
  211.  
  212.  
  213.        5.     Command formats are double-lined boxed.
  214.  
  215.  
  216.  
  217.        6.     Three dots either in vertical or horizontal alignment
  218.               mean continuation or that data is missing from diagram.
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  226. ‡                                                               ‡
  227. ‡        Multimax, Nanobus, and UMAX are trademarks of          ‡
  228. ‡        Encore Computer Corporation.                           ‡
  229. ‡                                                               ‡
  230. ‡                                                               ‡
  231. ‡        Annex is a trademark of XYLOGICS, Inc.                 ‡
  232. ‡                                                               ‡
  233. ‡                                                               ‡
  234. ‡        UNIX and Teletype are registered trademarks of         ‡
  235. ‡        AT&T Bell Laboratories                                 ‡
  236. ‡                                                               ‡
  237. ‡                                                               ‡
  238. ‡        Ethernet is a trademark of Xerox Corporation           ‡
  239. ‡                                                               ‡
  240. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  241. 1.  UNIX PROCESSES AND A FILE CALLED .profile
  242.  
  243.  
  244. 1.1  Processes
  245.  
  246.  
  247. A process is the execution of a command by UNIX.  Processes can
  248. also be executed by the operating system itself.  Like the file
  249. structure, the process structure is hierarchical.  It contains
  250. parents, children, and even a root.  A parent can fork (or spawn)
  251. a child process.  That child can, in turn, fork other processes.
  252. The first thing the operating system does to begin execution is
  253. to create a single process, PID number 1.  PID stands for Process
  254. Identification.  This process will hold the same position as the
  255. root directory in the file structure.  This process is the
  256. ancestor to all processes that each user works with.  It forks a
  257. process for each terminal.  Each one of these processes becomes a
  258. Shell process when the user logs in.
  259.  
  260. 1.2  Process Identification
  261.  
  262.  
  263. The UNIX operating system assigns a unique process identification
  264. number (PID) to each process.  It will keep the same PID as long
  265. as the process is in existence.  During one session, the same
  266. process is always executing the login Shell.  When you execute
  267. another command, a new process is forked and a new PID is
  268. assigned to that process.  When that child process is finished,
  269. you are returned to the login process, which is running the
  270. Shell, and that parent process has the same PID as when you
  271. logged in.
  272.  
  273.  
  274. The Shell stores the PID in Shell variable called $$.  The PID
  275. can also be shown with the process status (ps) command.  The
  276. format for ps is as follows:
  277.  
  278.  
  279. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  280. ”    Command Format:  ps [options]                              ”
  281. ”                                                               ”
  282. ”    See on-line manual for options                             ”
  283. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  284.  
  285. With no options given the ps command will give you certain
  286. information about processes associated with the controlling
  287. terminal.  The output consists of a short listing containing the
  288. process id, terminal id, cumulative execution time, and the
  289. command name.  Otherwise, options will control the display.
  290.  
  291. Sample session:
  292.  
  293. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  294. ‡ $echo $$                                                                   ‡
  295. ‡ 8347                                                                       ‡
  296. ‡ $ps                                                                        ‡
  297. ‡    PID TTY      TIME COMMAND                                               ‡
  298. ‡   8347 rt021a0  0:03 ksh                                                   ‡
  299. ‡   8376 rt021a0  0:06 ps                                                    ‡
  300. ‡ $                                                                          ‡
  301. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  302.  
  303.  
  304. The PID numbers of the Shell are the same in the sample session
  305. because the Shell will substitute its own PID number for $$. 
  306. The Shell makes the substitution before it forks a new process to
  307. execute the echo command.  Therefore, echo will display the PID
  308. number of the process that called it, not the PID of the process
  309. that is executing it.
  310. The -l option will display more information about the processes.
  311.  
  312.  
  313. Sample Session:
  314.  
  315. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  316. ‡ $ps -l                                                                                   ‡
  317. ‡     F S   UID   PID  PPID  C PRI NI     ADDR     SZ    WCHAN TTY      TIME COMD          ‡
  318. ‡ f0000 S   115  8347   309  2  30 20  1009000    140    94014 rt021a0  0:03 ksh           ‡
  319. ‡ f0000 O   115  8386  8347 16  68 20  1308000     72          rt021a0  0:01 ps            ‡
  320. ‡ $ps -l                                                                                   ‡
  321. ‡     F S   UID   PID  PPID  C PRI NI     ADDR     SZ    WCHAN TTY      TIME COMD          ‡
  322. ‡ f0000 S   115  8347   309  1  30 20  1009000    140    94014 rt021a0  0:03 ksh           ‡
  323. ‡ f0000 O   115  8387  8347 26  73 20  1146000     72          rt021a0  0:01 ps            ‡
  324. ‡ $                                                                                        ‡
  325. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  326.  
  327.  
  328. 1.3  Executing a Command
  329.  
  330.  
  331. When you give a command to the Shell, it will fork a process to
  332. execute the command.  While the child process is executing the
  333. command, the parent will go to sleep.  Sleeping means that the
  334. process will not use any CPU time.  It remains inactive until it
  335. is awakened.  When the child process has finished executing the
  336. command, it dies.  The parent process, which is running the
  337. Shell, wakes up and prompts you for another command.
  338.  
  339. When you request a process to run in the background (by ending
  340. the command line with an ampersand character (&), the Shell forks
  341. a child process that is allowed to run to completion.  The parent
  342. process will report the PID of the child process and then prompt
  343. you for another command.  The child and parent are now
  344. independent processes.
  345.  
  346.  
  347. 1.4  The . (dot) and exec Commands
  348.  
  349. There are two ways to execute a program without forking a new
  350. process. The . (dot) command will execute the script as part of
  351. the current process. When the new script has finished executing,
  352. the current process will continue to execute the original script. 
  353. The exec command will execute the new script in place of
  354. (overlays) the original script and never returns to the original
  355. script.
  356.  
  357. The . (dot) command will not execute compiled files (binary) and it does not require execute
  358. permission on the script file that is being executed. The exec command does require access
  359. permission to either a binary program or a shell script.
  360.  
  361.  
  362. Sample session:
  363.  
  364. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  365. ‡    $ls -l prog2                                               ‡
  366. ‡    -rw-r--r--  1 teacher  class   22 Jan 18 10:30 prog2       ‡
  367. ‡    $cat prog2                                                 ‡
  368. ‡    echo 'prog2 PID =' $$                                      ‡
  369. ‡    $cat dot_example                                           ‡
  370. ‡    echo $0 'PID=' $$                                          ‡
  371. ‡    . prog2                                                    ‡
  372. ‡    echo 'This line is executed'                               ‡
  373. ‡    $dot_example                                               ‡
  374. ‡    dot_example PID= 6942                                      ‡
  375. ‡    prog2 PID = 6942                                           ‡
  376. ‡    This line is executed                                      ‡
  377. ‡    $                                                          ‡
  378. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  379.  
  380. The exec command will overlay the sh and control will never return to the calling script.
  381. Let's look at another example with a call to prog2 using exec instead of . (dot):
  382.  
  383. Sample session:
  384.  
  385. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  386. ‡    $ls -l prog2                                               ‡
  387. ‡    -rwxr-xr-x  1 teacher  class   22 Jan 18 10:30 prog2       ‡
  388. ‡    $cat prog2                                                 ‡
  389. ‡    echo 'prog2 PID =' $$                                      ‡
  390. ‡    $cat exec_example                                          ‡
  391. ‡    echo $0 'PID=' $$                                          ‡
  392. ‡    exec prog2                                                 ‡
  393. ‡    echo 'This line is never executed'                         ‡
  394. ‡    $exec_example                                              ‡
  395. ‡    exec_example PID= 6950                                     ‡
  396. ‡    prog2 PID = 6950                                           ‡
  397. ‡    $                                                          ‡
  398. ‡                                                               ‡
  399. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  400.  
  401. Background Processing
  402.  
  403. When a program is running in background you do not have to wait for it to finish before
  404. starting another program. This is useful because you can start long/large jobs and then
  405. continue to do another task on your terminal.
  406.  
  407. To run a program in background simply type an ampersand character (&) at the end of the
  408. command line before the (Ret) key. The Shell will return the PID of the background process
  409. and then give you another system prompt.
  410.  
  411. Sample session:
  412.  
  413. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  414. ‡    $ls -l | lp &                                              ‡
  415. ‡    [1]     21334                                              ‡
  416. ‡    $request id is mt_600-2736 (standard input)                ‡
  417. ‡                                                               ‡
  418. ‡    $                                                          ‡
  419. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  420.  
  421. If the background task sends output to standard output and you fail to redirect it, the
  422. output will appear on your terminal even if you are running another program at the time. 
  423.  
  424. It is necessary to use the kill command to stop a process that is running in background the
  425. (DEL) key or its equivalent will not work.
  426.  
  427. Exit Status
  428.  
  429. When a process stops executing for any reason, it will return an exit status to the parent
  430. process. This exit status is also referred to as a condition code or return code.The Shell
  431. stores the exit status in a Shell variable called $?. By convention, a non-zero exit status
  432. means that it has a false value and the command failed. On the other hand, a zero status
  433. indicates true and the command was successful.
  434.  
  435. It is possible for you to specify the exit status when you exit a script. This is done by
  436. specifying the number to be used as the exit status using the exit command. The following
  437. script is an example:
  438.  
  439. Sample Session:
  440.  
  441. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  442. ‡    $cat exit_example                                          ‡
  443. ‡    echo 'This program returns an exit status'                 ‡
  444. ‡    echo 'of 7.'                                               ‡
  445. ‡    exit 7                                                     ‡
  446. ‡    $exit_example                                              ‡
  447. ‡    This program returns an exit status                        ‡
  448. ‡    of 7.                                                      ‡
  449. ‡    $echo $?                                                   ‡
  450. ‡    7                                                          ‡
  451. ‡    $echo $?                                                   ‡
  452. ‡    0                                                          ‡
  453. ‡    $                                                          ‡
  454. ‡                                                               ‡
  455. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  456.  
  457. This script will display the message and then exit with an exit code of 7. The exit status
  458. is stored in the Shell variable called $?. The second echo command above displays the exit
  459. status of the first echo command. Since it completed successfully it has a value of zero.
  460.  
  461. 1.4  Interrupt Handling
  462.  
  463.  
  464. A signal is a report to a process about a condition.  UNIX uses
  465. these signals to report bad system calls, broken pipes, illegal
  466. instructions, and other conditions.  There are three signals that
  467. are useful when programming in the Shell.  They are the terminal
  468. interrupt signal (number 2), the kill signal (number 9) and the
  469. software termination signal (number 15).
  470.  
  471. You can use the trap command to capture a signal and then take
  472. whatever action you specify.  It can close files or finish other
  473. processing that needs to be done, display a message, terminate
  474. execution immediately, or ignore the signal.
  475.  
  476. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  477. ”   Command Format: trap ['commands'] signal_numbers            ”
  478. ”                                                               ”
  479. ”   See online man pages for details                            ”
  480. ”                                                               ”
  481. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  482.  
  483. The signal_numbers are the numbers corresponding to the signals
  484. that will be trapped by the trap command.  There must be at least
  485. one number present.  The 'commands' portion of the command is
  486. optional.  If it is not present, the command resets the trap to
  487. its initial condition, which is to exit the program.  When the
  488. commands is present the Shell executes the commands when it
  489. catches one of the signals.  After executing the commands, the
  490. Shell continues executing the script where it left off.
  491.  
  492. You can interrupt a program you are running in the foreground by 
  493. pressing the Delete key.  When you press this key a signal
  494. (number 2), a terminal interrupt, to the program.  The Shell will
  495. terminate the execution of the program if the program does not
  496. trap the signal.  The following example demonstrates the trap
  497. command that will trap the signal and return an exit status of 1.
  498.  
  499. Sample session:
  500.  
  501. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  502. ‡    $cat inter                                                 ‡
  503. ‡    trap 'echo PROGRAM INTERRUPTED; exit 1' 2                  ‡
  504. ‡    while (true)                                               ‡
  505. ‡          do                                                   ‡
  506. ‡          echo 'Program running'                               ‡
  507. ‡          done                                                 ‡
  508. ‡    $                                                          ‡
  509. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  510. The first line of inter sets up a trap for signal number 2, the
  511. terminal interrupt.  When the signal is caught, the Shell will
  512. execute the commands between the two single quote marks.  In this
  513. example, the echo command will display PROGRAM INTERRUPTED.  The
  514. exit command will then return control to the Shell and a system
  515. prompt is displayed.  If the exit were missing, control would
  516. revert to the while loop after displaying the message.
  517.  
  518. You can send a software termination to a background process using
  519. the kill command without a signal number.  However, a trap
  520. command can be set to catch this signal (number 15).  A kill
  521. signal can be sent to kill a process with a signal number 9 and
  522. the Shell cannot catch a kill signal.
  523.  
  524.  
  525. The file called .profile
  526.  
  527. The BourneShell declares and initializes variables that determine
  528. such things as your home directory, what directories the Shell
  529. will look in when you give commands, how often to look for mail,
  530. your system prompt, and many other things.  We will look at some
  531. of these Shell variables and their functions.  You can assign new
  532. values to these variables from the command line or by executing
  533. the contents of a file called .profile.  The BourneShell executes
  534. the commands in this file in the same environment as the Shell
  535. each time the user logs in.  The .profile must be in the user'
  536. home directory.  Each user has a different .profile.  It usually
  537. specifies the terminal type and establishes terminal
  538. characteristics and other housekeeping functions as required by
  539. the user.
  540.  
  541.  
  542.  
  543. 1.5  HOME
  544.  
  545. The first BourneShell variable that we will look at is the HOME
  546. variable.  By default, the home directory is the current working
  547. directory after you login.  The system administrator determines
  548. your home directory when you establish an account and places that
  549. information in the /etc/passwd file.  When you login, the
  550. BourneShell gets that pathname and assigns it to the HOME
  551. variable.
  552.  
  553. When you enter a cd command with no argument, the utility takes
  554. the name of the directory from the HOME variable and makes it the
  555. current working directory.  If you change the HOME variable to
  556. another directory pathname, the utility will make the new
  557. directory the current working directory.
  558.  
  559.  
  560.  
  561.  
  562. Sample Session:
  563.  
  564. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  565. ‡ $echo $HOME                                                   ‡
  566. ‡ /user0/rharding                                               ‡
  567. ‡ $cd                                                           ‡
  568. ‡ $pwd                                                          ‡
  569. ‡ /user0/rharding                                               ‡
  570. ‡ $HOME=/user0/rharding/eng                                     ‡
  571. ‡ $cd                                                           ‡
  572. ‡ $pwd                                                          ‡
  573. ‡ /user0/rharding/eng                                           ‡
  574. ‡ $                                                             ‡
  575. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  576.  
  577. This example shows how the value of the HOME variable affects the
  578. cd utility.  The cd command will use the value of the HOME
  579. variable as the pathname for the current working directory.
  580.  
  581.  
  582. 1.6  PATH
  583.  
  584. This BourneShell variable will describe the directories that will
  585. be searched looking for the program that you want to execute. 
  586. The BourneShell looks in several directories for a file that has
  587. the same name as the command that you entered.  The PATH variable
  588. controls this search path.  Normally, the first directory
  589. searched is the current working directory.  If the program is not
  590. found, the search continues in the /bin and then the /usr/bin
  591. directory.  Generally, these directories contain executable
  592. programs.  If the program is not found in one of these
  593. directories, the BourneShell reports that the program can't be
  594. found (or executed).
  595.  
  596. The PATH variable lists the pathnames in the order in which the
  597. search will proceed.  The pathnames are separated by a colon (:).
  598. If nothing (null string) precedes the colon, that indicates to
  599. start the search at the current working directory.
  600.  
  601. Example:
  602. .................................................................
  603. . $PATH=:/user0/rharding/bin:/bin:/usr/bin                      .
  604. . $                                                             .
  605. .................................................................
  606.  
  607. This PATH variable indicates to start the search for the program
  608. at the current working directory, then look in the directory
  609. /user0/rharding/bin, then /bin, and finally /usr/bin.
  610.  
  611. If each user has a unique path specified, each user can execute a
  612. different program by giving the same command.  The search for the
  613. program stops when it is satisfied; thus, you can use the same
  614. name for your own programs as the standard UNIX utilities.  To do
  615. this, simply put your program in one of the first directories
  616. that the BourneShell searches.
  617. 1.7  INGRES Environment Variables
  618.  
  619.  
  620. There are some environment variables that need to be in the
  621. .profile that set up INGRES.  The following examples are given as
  622. general guidelines, not actual entries to be made in your
  623. .profile.
  624.  
  625.  
  626. 1.8  ING_HOME
  627.  
  628.  
  629. This is the INGRES home directory. This variable is valid for
  630. version 5 of INGRES. This variable is set up in the following
  631. manner.
  632.  
  633. Example:
  634.  
  635. .................................................................
  636. .    $ING_HOME=/user5/ingres                                    .
  637. .................................................................
  638.  
  639. Notice that this environment variable is all capital letters.
  640. This is a requirement in UNIX.
  641.  
  642.  
  643.  
  644. 1.9  TERM_INGRES
  645.  
  646.  
  647. If this variable is not set, INGRES will use the default terminal 
  648. type defined by the TERM variable in UNIX.  It is not required
  649. but difficulty in using the main INGRES menu can be experienced
  650. if it is not used.
  651.  
  652.  
  653. Example:
  654.  
  655. .................................................................
  656. .    $TERM_INGRES=vt100f                                        .
  657. .................................................................
  658.  
  659. 1.10  ING_EDIT
  660.  
  661.  
  662. This variable defines the editor to use any time a user enters a
  663. command that requires the use of an editor.  The default is to
  664. use the 'ed'  editor. 
  665.  
  666. Example:
  667.  
  668. .................................................................
  669. .   $ING_EDIT=/usr/bin/vi                                       .
  670. .................................................................
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680. Workshop 1
  681.  
  682. This workshop will reinforce your understanding of the material
  683. presented in this chapter. Login using the username and the
  684. password given to you by the instructor.  Each student is to
  685. complete the entire workshop.
  686.  
  687. DESK EXERCISES
  688.  
  689.  
  690.  
  691.        1. What is the name of the file that is executed from your
  692.           home directory every time you log in?
  693.  
  694.  
  695.  
  696.  
  697.  
  698.        2. What does the Shell variable HOME represent?
  699.  
  700.  
  701.  
  702.  
  703.  
  704.        3. What does the Shell variable PATH represent?
  705.  
  706.  
  707.  
  708.  
  709.        4. What is a UNIX process?
  710.  
  711.  
  712.  
  713.  
  714.  
  715.        5. When a command is given to the Shell it will fork a child 
  716.           process to execute the command.
  717.  
  718.                          True/False
  719.  
  720.  
  721.  
  722.        6. What is a process identification number (PID)?
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.                                   Continue on the next page
  732.        7. What is the purpose of the trap command?
  733.  
  734.  
  735.  
  736.  
  737.  
  738. COMPUTER EXERCISES
  739.  
  740.  
  741.  
  742.        8. Logon 
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.        9. What is the PID of your process?                     
  750.  
  751.  
  752.  
  753.  
  754.  
  755.        10. Edit the .profile to include your home directory in the  
  756.            path.
  757.  
  758.  
  759.  
  760.  
  761.  
  762.        11. Modify the .profile so every time you login a listing of 
  763.            the files in your current working directory (HOME) is  
  764.            displayed. 
  765.  
  766.  
  767.  
  768.  
  769.        12. Send a long listing of all the files in the current      
  770.            working directory to the default printer and do it it  
  771.            the background. 
  772.  
  773.  
  774.  
  775.  
  776.  
  777.        13. Logoff
  778.  
  779.  
  780.                                             NOTES
  781. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  782. 2. COMPILING "C" PROGRAMS
  783.  
  784. This chapter will examine compiling source code programs in three
  785. high level languages "C", FORTRAN, and COBOL.  The second part of
  786. the chapter will look at the archive and library maintainer.  The
  787. archive allows you to create a library of object modules.  These
  788. files are used by the link editor.
  789.  
  790. 2.1  "C": Sample Program with a Main and Two Functions in One     
  791.      File
  792.  
  793. Based on the command line options, cc compiles, assembles, and
  794. loads C language source code programs.  It can also assemble and
  795. load assembly language source programs or merely load object
  796. programs.
  797.  
  798. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  799. ”  Command Format:  cc [options] file-list                      ”
  800. ”                                                               ”
  801. ”  (See Appendix E for a complete list of options)              ”
  802. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  803.  
  804. When using the cc utility, the following conventions are
  805. observed:
  806.  
  807.        1.     A filename with the extension of .c indicates a C
  808.               language source program.
  809.  
  810.        2.     A filename with an extension of .s indicates an
  811.               assembly language source program.
  812.  
  813.        3.     A filename with an extension of .o indicates an object
  814.               program.
  815.  
  816.  
  817. The cc utility will take its input from the file or files you
  818. specify on the command line.  Unless you use the -o option, it
  819. will store the executable program in a file called a.out.
  820. Sample C Language Source Code Program:
  821.                            
  822. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  823. ‡ $cat hello.c                                                  ‡
  824. ‡ main ()                                                       ‡
  825. ‡ {                                                             ‡
  826. ‡      printf ("Hello from main!\n\n");                         ‡
  827. ‡      printf ("Calling function1!\n\n");                       ‡
  828. ‡      funct1();                                                ‡
  829. ‡      printf ("\t Back from function1!\n\n");                  ‡
  830. ‡      printf ("Calling function2!\n\n");                       ‡
  831. ‡      funct2();                                                ‡
  832. ‡      printf ("\t Back from funct2!\n\n");                     ‡
  833. ‡      printf ("That's all!\n\n");                              ‡
  834. ‡ }                                                             ‡
  835. ‡ funct1()                                                      ‡
  836. ‡ {                                                             ‡
  837. ‡      printf ("\t\t Hello from function1!\n\n);                ‡
  838. ‡ }                                                             ‡
  839. ‡ funct2()                                                      ‡
  840. ‡ {                                                             ‡
  841. ‡      printf ("\t\t Hello from function2!\n\n);                ‡
  842. ‡ }                                                             ‡
  843. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  844. 2.2  "C": Compiling a Program
  845.  
  846. To compile the previous example program into an executable
  847. module, enter the following command at the command line.
  848.  
  849. Sample Session:
  850.  
  851. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  852. ‡ $cc hello.c                                                   ‡
  853. ‡ $                                                             ‡
  854. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  855.  
  856. Without any options, cc accepts C source code and assembly
  857. language programs that follow the conventions outlined above.  It
  858. will compile, assemble, and load these programs to produce an
  859. executable called a.out.  The cc utility puts the object code in
  860. files with the same base filename (everything before the period)
  861. as the source but with a filename extension of .o.  The a.out
  862. stands for assembly output.  This is the default.
  863.  
  864. Sample Session:
  865.  
  866. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  867. ‡ $cc hello.c                                                   ‡
  868. ‡ $a.out                                                        ‡
  869. ‡ Hello from main!                                              ‡
  870. ‡                                                               ‡
  871. ‡ Calling function1!                                            ‡
  872. ‡                                                               ‡
  873. ‡                Hello from function1!                          ‡
  874. ‡                                                               ‡
  875. ‡           Back from function1!                                ‡
  876. ‡                                                               ‡
  877. ‡ Calling function2!                                            ‡
  878. ‡                                                               ‡
  879. ‡                Hello from function2!                          ‡
  880. ‡                                                               ‡
  881. ‡           Back from function2!                                ‡
  882. ‡                                                               ‡
  883. ‡ That's all!                                                   ‡
  884. ‡ $                                                             ‡
  885. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  886.  
  887. NOTE:         The a.out file that was created by the cc utility has
  888.               the following permissions:
  889.  
  890.               user  - read, write, and execute 
  891.               group - read and execute
  892.               other - read and execute
  893.  
  894. It is not necessary for you to change the permissions using the
  895. chmod command because the cc utility set the execute permissions
  896. for you.
  897.  
  898. 2.3  "C": Renaming the Executable Module
  899.  
  900.  
  901. You can rename the executable module using the mv command.  The
  902. file permissions will be the same as before the file is renamed.
  903.  
  904. Sample Session:
  905.  
  906. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  907. ‡ $mv a.out hello                                               ‡
  908. ‡ $hello                                                        ‡
  909. ‡ Hello from main!                                              ‡
  910. ‡                                                               ‡
  911. ‡ Calling function1!                                            ‡
  912. ‡                                                               ‡
  913. ‡                Hello from function1!                          ‡
  914. ‡                                                               ‡
  915. ‡           Back from function1!                                ‡
  916. ‡                                                               ‡
  917. ‡ Calling function2!                                            ‡
  918. ‡                                                               ‡
  919. ‡                Hello from function2!                          ‡
  920. ‡                                                               ‡
  921. ‡           Back from function2!                                ‡
  922. ‡                                                               ‡
  923. ‡ That's all!                                                   ‡
  924. ‡ $                                                             ‡
  925. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  926. 2.4  "C": Giving a Name to the Output File
  927.  
  928.  
  929. It is possible to have the output sent to a file you specify
  930. instead of a.out by using the following command.
  931.  
  932. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  933. ”  Command Format:  cc -o output source                         ”
  934. ”                                                               ”
  935. ”  output - the name of the executable file                     ”
  936. ”                                                               ”
  937. ”  source - the name of the C source code file                  ”
  938. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝… 
  939.                                                                
  940. The -o option tells cc to tell the link editor to use the
  941. specified name for the output instead of the default a.out.
  942.  
  943. NOTE:         It is not necessary for the -o option to appear after
  944.               the cc command.  The filename that appears after the -o
  945.               is the name of the output file.  For example, cc source
  946.               -o output is the same as cc -o output source.
  947.  
  948. Sample Session:
  949.  
  950. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  951. ‡ $cc -o hello.c                                                ‡
  952. ‡ $hello                                                        ‡
  953. ‡ Hello from main!                                              ‡
  954. ‡ Calling function1!                                            ‡
  955. ‡                                                               ‡
  956. ‡                Hello from function1!                          ‡
  957. ‡                                                               ‡
  958. ‡           Back from function1!                                ‡
  959. ‡                                                               ‡
  960. ‡ Calling function2!                                            ‡
  961. ‡                                                               ‡
  962. ‡                Hello from function2!                          ‡
  963. ‡                                                               ‡
  964. ‡           Back from function2!                                ‡
  965. ‡                                                               ‡
  966. ‡ That's all!                                                   ‡
  967. ‡ $                                                             ‡
  968. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  969. 2.5  "C": Producing an Assembly Listing
  970.  
  971.  
  972. This option causes cc to compile C programs and leave the
  973. corresponding assembly language source programs in a file with
  974. filename extensions of .s.
  975.  
  976. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  977. ”  Command Format:  cc -S hello.c                               ”
  978. ”                                                               ”
  979. ”  -S = Compile only                                            ”
  980. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  981.  
  982. Sample Session:
  983.  
  984. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  985. ‡ $cc -S  hello.c                                               ‡
  986. ‡ $ls -C                                                        ‡
  987. ‡ example.f    hello     hex.c     octal.c                      ‡
  988. ‡ hello.c      hello.s   multiply.c                             ‡
  989. ‡ $                                                             ‡
  990. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  991. 2.6  "C": Main and Two Functions in Three Separate Source Files
  992.  
  993.  
  994. This is the same C program that we have seen before, except it is
  995. now in three files rather than one as before.  The three files
  996. are main.c, funct1.c, and funct2.c.
  997.  
  998.  
  999. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1000. ‡ $cat main.c                                                   ‡
  1001. ‡ main ()                                                       ‡
  1002. ‡ {                                                             ‡
  1003. ‡      printf ("Hello from main!\n\n");                         ‡
  1004. ‡      printf ("Calling function1!\n\n");                       ‡
  1005. ‡      funct1();                                                ‡
  1006. ‡      printf ("\t Back from function1!\n\n");                  ‡
  1007. ‡      printf ("Calling function2!\n\n");                       ‡
  1008. ‡      funct2();                                                ‡
  1009. ‡      printf ("\t Back from funct2!\n\n");                     ‡
  1010. ‡      printf ("That's all!\n\n");                              ‡
  1011. ‡ }                                                             ‡
  1012. ‡ $cat funct1.c                                                 ‡
  1013. ‡ funct1()                                                      ‡
  1014. ‡ {                                                             ‡
  1015. ‡      printf ("\t\t Hello from function1!\n\n);                ‡
  1016. ‡ }                                                             ‡
  1017. ‡ $cat funct2.c                                                 ‡
  1018. ‡ funct2()                                                      ‡
  1019. ‡ {                                                             ‡
  1020. ‡      printf ("\t\t Hello from function2!\n\n);                ‡
  1021. ‡ }                                                             ‡
  1022. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1023. 2.7  "C": Compiling but Not Producing an Executable Module
  1024.  
  1025.  
  1026. Using the previous program, the following command will compile
  1027. but not produce an executable module.
  1028.  
  1029. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  1030. ”     Command Format:     cc -c main.c funct1.c funct2.c        ”
  1031. ”                                                               ”
  1032. ”     -c = Compile, but do not load object files.  This option  ”
  1033. ”          causes cc to compile and/or assemble source code     ”
  1034. ”          programs and leave the corresponding object programs ”
  1035. ”          in files with filename extensions of .o.             ”
  1036. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  1037.  
  1038. Sample Session:
  1039.  
  1040. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1041. ‡ $cc -c main.c funct1.c funct2.c                               ‡
  1042. ‡ main.c:                                                       ‡
  1043. ‡ funct1.c:                                                     ‡
  1044. ‡ funct2.c:                                                     ‡
  1045. ‡ $ls a.out                                                     ‡
  1046. ‡ a.out not found                                               ‡
  1047. ‡ $ls -C *.o                                                    ‡
  1048. ‡ funct1.o           funct2.o          main.o                   ‡
  1049. ‡ $                                                             ‡
  1050. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1051.  
  1052. The -c options causes the compilation system to suppress the link
  1053. edit phase.  This produces an object file or files, in this
  1054. example (main.o funct1.o funct2.o), that can be link edited at a
  1055. later time with the cc command with no options.
  1056. 3.  COMPILING FORTRAN  PROGRAMS
  1057.  
  1058. 3.1  FORTRAN: Sample Program a Main and Two Subroutines
  1059.  
  1060.  
  1061. There are several conventions for use with the FORTRAN compiler.
  1062. They are:
  1063.  
  1064.        1.     The name of the file containing the FORTRAN source code
  1065.               must end with .f.
  1066.  
  1067.        2.     The compiler is invoked with f77.
  1068.  
  1069.        3.     Several options are available with the compiler.
  1070.               (-c, -o, -p, -S)
  1071.  
  1072.        4.     Preconnections are made for stdin (unit5) and stdout
  1073.               (unit6).
  1074.  
  1075. This is the FORTRAN source code example to be used in the
  1076. following discussions of the FORTRAN compiler.
  1077.  
  1078. Sample Session:
  1079.  
  1080. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1081. ‡ $cat hello.f                                                  ‡
  1082. ‡       program calling                                         ‡
  1083. ‡       write(6,100)                                            ‡
  1084. ‡ 100   format (' Hello from main!',/)                          ‡
  1085. ‡       write(6,110)                                            ‡
  1086. ‡ 110   format(' Calling subroutine1!',/)                       ‡
  1087. ‡       call sub1                                               ‡
  1088. ‡       write(6,120)                                            ‡
  1089. ‡ 120   format(t15' Back from subroutine1!',/)                  ‡
  1090. ‡       write(6,130)                                            ‡
  1091. ‡ 130   format(' Calling subroutine2!',/)                       ‡
  1092. ‡       call sub2                                               ‡
  1093. ‡       write(6,140)                                            ‡
  1094. ‡ 140   format(t15' Back from subroutine2!',/)                  ‡
  1095. ‡       write(6,150)                                            ‡
  1096. ‡ 150   format(' That's all, folks!')                           ‡
  1097. ‡       end                                                     ‡
  1098. ‡       subroutine sub1                                         ‡
  1099. ‡       write(6,200)                                            ‡
  1100. ‡ 200   format(t20,' Hello from subroutine1!',/)                ‡
  1101. ‡       end                                                     ‡
  1102. ‡       subroutine sub2                                         ‡
  1103. ‡       write(6,210)                                            ‡
  1104. ‡ 210   format(t20,' Hello from subroutine2!',/)                ‡
  1105. ‡       end                                                     ‡
  1106. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1107. 3.2  FORTRAN: Compiling a Program
  1108.  
  1109.  
  1110. The FORTRAN compiler is invoked with the following command:
  1111.  
  1112. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  1113. ”  Command Format:  f77                                         ”
  1114. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  1115.  
  1116. To compile the above program into an executable program, use the
  1117. following command at the command line.
  1118.  
  1119. Sample Session:
  1120.  
  1121. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1122. ‡ $f77 hello.f                                                  ‡
  1123. ‡ $                                                             ‡
  1124. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1125.  
  1126. Without any options, f77 accepts FORTRAN source code and assembly
  1127. language programs that follow the conventions outlined above.  It
  1128. will compile, assemble, and load these programs to produce an
  1129. executable called a.out.  The f77 utility outputs the object code
  1130. into files with the same base filename (everything before the
  1131. period) as the source but with a filename extension of .o.
  1132. The a.out stands for assembly output.  This is the default.
  1133.  
  1134. Sample Session:
  1135.  
  1136. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1137. ‡ $f77 hello.f                                                  ‡
  1138. ‡ $a.out                                                        ‡
  1139. ‡ Hello from main!                                              ‡
  1140. ‡                                                               ‡
  1141. ‡ Calling function1!                                            ‡
  1142. ‡                                                               ‡
  1143. ‡              Hello from function1!                            ‡
  1144. ‡                                                               ‡
  1145. ‡         Back from function1!                                  ‡
  1146. ‡                                                               ‡
  1147. ‡ Calling function2!                                            ‡
  1148. ‡                                                               ‡
  1149. ‡              Hello from function2!                            ‡
  1150. ‡                                                               ‡
  1151. ‡         Back from function2!                                  ‡
  1152. ‡                                                               ‡
  1153. ‡ That's all!                                                   ‡
  1154. ‡ $                                                             ‡
  1155. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1156.  
  1157.  
  1158. NOTE:         The a.out file that was created by the f77 utility has
  1159.               the following permissions:
  1160.  
  1161.               user - read, write, and execute 
  1162.               group - read and execute
  1163.               other - read and execute
  1164.  
  1165. It is not necessary for you to change the permissions using the
  1166. chmod command because the f77 utility set the execute permissions
  1167. for you.
  1168.  
  1169.  
  1170.  
  1171. 3.3  FORTRAN: Renaming the Executable Module
  1172.  
  1173.  
  1174. You can rename the executable module using the mv command.  The
  1175. file permissions will be the same as before the file is renamed.
  1176.  
  1177. Sample Session:
  1178.  
  1179. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1180. ‡ $mv a.out hello                                               ‡
  1181. ‡ $hello                                                        ‡
  1182. ‡ Hello from main!                                              ‡
  1183. ‡                                                               ‡
  1184. ‡ Calling function1!                                            ‡
  1185. ‡                                                               ‡
  1186. ‡              Hello from function1!                            ‡
  1187. ‡                                                               ‡
  1188. ‡         Back from function1!                                  ‡
  1189. ‡                                                               ‡
  1190. ‡ Calling function2!                                            ‡
  1191. ‡                                                               ‡
  1192. ‡              Hello from function2!                            ‡
  1193. ‡                                                               ‡
  1194. ‡         Back from function2!                                  ‡
  1195. ‡                                                               ‡
  1196. ‡ That's all!                                                   ‡
  1197. ‡ $                                                             ‡
  1198. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1199. 3.4  FORTRAN: Giving a Name to the Output File
  1200.  
  1201.  
  1202. It is possible to have the output sent to a file you specify
  1203. instead of the default, a.out, by using the following command.
  1204.  
  1205. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  1206. ”  Command Format:  f77 -o output source                        ”
  1207. ”                                                               ”
  1208. ”  output - the name of the executable file                     ”
  1209. ”                                                               ”
  1210. ”  source - the name of the Fortran source code file            ”
  1211. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝… 
  1212.                                                                
  1213. The -o option tells the f77 utility to tell the link editor to
  1214. use the specified name for the output instead of the default
  1215. a.out.
  1216.  
  1217. NOTE:         It is not necessary for the -o option to appear after
  1218.               the f77 command.  The filename that appears after the -
  1219.               o is the name of the output file.  For example, f77
  1220.               source -o output is the same as f77 -o output source.
  1221.  
  1222. Sample Session:
  1223.  
  1224. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1225. ‡ $f77 -o hello.f                                               ‡
  1226. ‡ $hello                                                        ‡
  1227. ‡ Hello from main!                                              ‡
  1228. ‡ Calling function1!                                            ‡
  1229. ‡                                                               ‡
  1230. ‡              Hello from function1!                            ‡
  1231. ‡                                                               ‡
  1232. ‡         Back from function1!                                  ‡
  1233. ‡                                                               ‡
  1234. ‡ Calling function2!                                            ‡
  1235. ‡                                                               ‡
  1236. ‡              Hello from function2!                            ‡
  1237. ‡                                                               ‡
  1238. ‡         Back from function2!                                  ‡
  1239. ‡                                                               ‡
  1240. ‡ That's all!                                                   ‡
  1241. ‡ $                                                             ‡
  1242. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1243. 3.5  FORTRAN: Producing an Assembly Listing
  1244.  
  1245.  
  1246. This option causes f77 to compile Fortran programs and leave the
  1247. corresponding assembly language source programs in a file with
  1248. filename extensions of .s.
  1249.  
  1250. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  1251. ”  Command Format:  f77 -S hello.f                              ”
  1252. ”                                                               ”
  1253. ”  -S = Compile only                                            ”
  1254. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  1255.  
  1256. Sample Session:
  1257.  
  1258. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1259. ‡ $f77 -S  hello.f                                              ‡
  1260. ‡ $ls -C                                                        ‡
  1261. ‡ example.f         hello     hex.c     octal.c                 ‡
  1262. ‡ hello.c           hello.s   multiply.c                        ‡
  1263. ‡ $                                                             ‡
  1264. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1265.  
  1266. The file hello.s contains the assembly listing.
  1267. 3.6  FORTRAN: Main and Two Subroutines in Three Separate Source                            
  1268. Files
  1269.  
  1270.  
  1271. Sample Session:
  1272.  
  1273. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1274. ‡ $cat main.f                                                   ‡
  1275. ‡      program calling                                          ‡
  1276. ‡      write(6,100)                                             ‡
  1277. ‡ 100  format (' Hello from main!',/)                           ‡
  1278. ‡      write(6,110)                                             ‡
  1279. ‡ 110  format(' Calling subroutine1!',/)                        ‡
  1280. ‡      call sub1                                                ‡
  1281. ‡      write(6,120)                                             ‡
  1282. ‡ 120  format(t15' Back from subroutine1!',/)                   ‡
  1283. ‡      write(6,130)                                             ‡
  1284. ‡ 130  format(' Calling subroutine2!',/)                        ‡
  1285. ‡      call sub2                                                ‡
  1286. ‡      write(6,140)                                             ‡
  1287. ‡ 140  format(t15' Back from subroutine2!',/)                   ‡
  1288. ‡      write(6,150)                                             ‡
  1289. ‡ 150  format(' That's all, folks!')                            ‡
  1290. ‡      end                                                      ‡
  1291. ‡ $cat sub1.f                                                   ‡
  1292. ‡      subroutine sub1                                          ‡
  1293. ‡      write(6,200)                                             ‡
  1294. ‡ 200  format(t20,' Hello from subroutine1!',/)                 ‡
  1295. ‡      end                                                      ‡
  1296. ‡ $cat sub2.f                                                   ‡
  1297. ‡      subroutine sub2                                          ‡
  1298. ‡      write(6,210)                                             ‡
  1299. ‡ 210  format(t20,' Hello from subroutine2!',/)                 ‡
  1300. ‡      end                                                      ‡
  1301. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1302. 3.7  FORTRAN: Compiling But Not Producing an Executable Module
  1303.  
  1304.  
  1305. Using the above program, the following command will compile but
  1306. not produce an executable module.
  1307.  
  1308. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  1309. ”  Command Format:  f77 -c main.f sub1.f sub2.f                 ”
  1310. ”                                                               ”
  1311. ”  -c = Compile, but do not load object files.  This option     ”
  1312. ”       causes f77 to compile and/or assemble source code       ”
  1313. ”       programs and leave the corresponding object programs    ”
  1314. ”       in files with filename extensions of .o.                ”
  1315. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  1316.  
  1317. Sample Session:
  1318.  
  1319. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1320. ‡ $f77 -c main.f sub1.f sub2.f                                  ‡
  1321. ‡ main.f:                                                       ‡
  1322. ‡      MAIN: calling:                                           ‡
  1323. ‡ sub1.f:                                                       ‡
  1324. ‡      sub1:                                                    ‡
  1325. ‡ sub2.f:                                                       ‡
  1326. ‡      sub2:                                                    ‡
  1327. ‡ $ls a.out *.o                                                 ‡
  1328. ‡ a.out not found                                               ‡
  1329. ‡ funct1.o                                                      ‡
  1330. ‡ funct2.o                                                      ‡
  1331. ‡ hello.o                                                       ‡
  1332. ‡ main.o                                                        ‡
  1333. ‡ sub1.o                                                        ‡
  1334. ‡ sub2.o                                                        ‡
  1335. ‡ $                                                             ‡
  1336. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1337.  
  1338. The -c options causes the compilation system to suppress the link
  1339. edit phase.  This produces an object file or files, in this
  1340. example (main.o sub1.o sub2.o), that can be link edited at a
  1341. later time with the f77 command with no options.
  1342. 3.8  FORTRAN: Compiling Object Files to Produce an Executable                               
  1343.       Module
  1344.  
  1345.  
  1346. The command to produce an executable nodule from several object
  1347. files is done in the following manner:
  1348.  
  1349. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  1350. ”  Command Format:  f77 obj_1 obj_2 obj_3                       ”
  1351. ”                                                               ”
  1352. ”  obj_1 through obj_n - the object files                       ”
  1353. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  1354.  
  1355. Sample Session:
  1356.  
  1357. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1358. ‡ $f77 main.o sub1.o sub2.o                                     ‡
  1359. ‡ $ls -C                                                        ‡
  1360. ‡ funct1.o funct2.o hello.o main.o sub1.o sub2.o a.out          ‡
  1361. ‡ $                                                             ‡
  1362. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1363. 4.  COMPILING COBOL PROGRAMS
  1364.  
  1365. 4.1  COBOL: Sample Program with a Main and Two Subroutines
  1366.  
  1367.  
  1368. Sample Session:
  1369.  
  1370. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1371. ‡ $cat teacher.cob                                              ‡
  1372. ‡ identification division.                                      ‡
  1373. ‡ program-id. teacher.                                          ‡
  1374. ‡ environment division.                                         ‡
  1375. ‡ configuration section.                                        ‡
  1376. ‡ data division.                                                ‡
  1377. ‡ working-storage section.                                      ‡
  1378. ‡ procedure division.                                           ‡
  1379. ‡ begin section.                                                ‡
  1380. ‡ begin-it.                                                     ‡
  1381. ‡      display " Hello from main!".                             ‡
  1382. ‡      display "  Calling subroutine1!".                        ‡
  1383. ‡      perform subroutine1.                                     ‡
  1384. ‡      display "               Back from subroutine1!".         ‡
  1385. ‡      display "  Calling subroutine2!".                        ‡
  1386. ‡      perform subroutine2.                                     ‡
  1387. ‡      display "               Back from subroutine2!".         ‡
  1388. ‡      display "  That's all, folks!".                          ‡
  1389. ‡      stop run.                                                ‡
  1390. ‡ subroutine1 section.                                          ‡
  1391. ‡ sub1.                                                         ‡
  1392. ‡      display "               Hello from subroutine1!".        ‡
  1393. ‡ subroutine2 section.                                          ‡
  1394. ‡ sub2.                                                         ‡
  1395. ‡      display "               Hello from subroutine2!".        ‡
  1396. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1397. 4.2  COBOL: Compiling a Program
  1398.  
  1399.  
  1400. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  1401. ”  Command Format:  cobol source_filename                       ”
  1402. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  1403.  
  1404. Three files are created by the compiler.  They are identified by
  1405. the same filename as the source code but with a different
  1406. extension.  They have the extensions .IDY, .INT, and .LST.
  1407.  
  1408. NOTE:         These extensions are uppercase characters.  UNIX is
  1409.               case sensitive.
  1410.  
  1411.  
  1412. Sample Session:
  1413.  
  1414. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1415. ‡ $cobol teacher.cob                                            ‡
  1416. ‡ $ls teacher*                                                  ‡
  1417. ‡ teacher.IDY                                                   ‡
  1418. ‡ teacher.INT                                                   ‡
  1419. ‡ teacher.LST                                                   ‡
  1420. ‡ teacher.cob                                                   ‡
  1421. ‡ $                                                             ‡
  1422. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1423. 4.3  COBOL: Running a Program
  1424.  
  1425.  
  1426. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1427. ‡ $cbrun teacher.INT                                            ‡
  1428. ‡ Hello from Main!                                              ‡
  1429. ‡   Calling subroutine1!                                        ‡
  1430. ‡               Hello from subroutine1!                         ‡
  1431. ‡              Back from subroutine1!                           ‡
  1432. ‡   Calling subroutine2!                                        ‡
  1433. ‡               Hello from subroutine2!                         ‡
  1434. ‡              Back from subroutine2!                           ‡
  1435. ‡ That's all, folks!                                            ‡
  1436. ‡ $                                                             ‡
  1437. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1438.  
  1439.                                             NOTES
  1440. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  1441. Workshop 2 through 4
  1442.  
  1443.  
  1444. This workshop will reinforce your understanding of the ideas
  1445. presented in this chapter.  Login using the username and password
  1446. given to you by the instructor.  Each student is to complete the
  1447. entire workshop.
  1448.  
  1449. DESK EXERCISES
  1450.  
  1451.  
  1452.        1.     "C": What is the command to compile, assemble, and load
  1453.               source code programs?
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.  
  1460.        2.     "C": What is the filename extension that indicates a
  1461.               source code program? An assembly language program? An
  1462.               object code file?
  1463.  
  1464.  
  1465.  
  1466.  
  1467.  
  1468.  
  1469.        3.     "C": What is the default filename assigned to the
  1470.               executable file?
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.        4.     "C": What command can be used to rename the executable
  1479.               file produced by the cc compiler? What are the file
  1480.               protections associated with the executable?
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.        5.     "C": What option will produce an assembly listing? What
  1489.               is the filename extension of this file?
  1490.  
  1491.  
  1492.                                 Continue on the next page   
  1493.        6.     "C": What command will compile the source code program
  1494.               but will not load object files but will keep the object
  1495.               files in files with extensions of .o?
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.        7.     FORTRAN: What is the command to invoke the compiler?
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.        8.     FORTRAN: What is the filename extension for source code
  1510.               programs?
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.        9.     FORTRAN: What is the name of the default
  1519.               executable file?
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.        10.    FORTRAN: How can you change the permissions on the
  1528.               executable module so anyone can execute it?
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.        11.    FORTRAN: What option on the call to the compiler will
  1537.               allow you to specify the name of the executable file?
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.                                   Continue on the next page
  1544.        12.    FORTRAN: What option on the call to the compiler will
  1545.               produce an assembly listing?  What is the filename
  1546.               extension of this file?
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.        13.    FORTRAN: What option will produce object modules but
  1553.               not produce an executable module?
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.        14.    FORTRAN: What command will produce an executable module
  1561.               from several object modules?
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.        15.    COBOL: What is the command to call the compiler?
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.        16.    COBOL: What are the three files created by the
  1578.               compiler? What are the filename extensions?
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.        17.    COBOL: Which of the three files that have been created
  1587.               are used to run the program?
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.                                   Continue on the next page
  1596. COMPUTER EXERCISES 
  1597.  
  1598.  
  1599.        18.    Copy the following files from the directory 
  1600.               teacher:
  1601.  
  1602.               main.c   funct1.c   funct2.c
  1603.  
  1604.  
  1605.        Are these programs "C", FORTRAN, or COBOL? Compile these
  1606.        three files creating an executable file called main1.exe and
  1607.        then execute it.  What are the file protections? Why?
  1608.  
  1609.  
  1610.  
  1611.        19.    Now append the three files into one file. 
  1612.               Use output redirection. 
  1613.  
  1614.        Compile the file creating the executable file called
  1615.        main2.exe.  Execute main2.exe.
  1616.  
  1617.  
  1618.  
  1619.  
  1620.        20.    Copy the following files from teacher into your         
  1621.               home directory:
  1622.  
  1623.               main.f   sub1.f   sub2.f
  1624.  
  1625.  
  1626.               Compile these three files creating an executable file
  1627.               called main1.exe.  Execute main1.exe
  1628.  
  1629.  
  1630.        21.    Now append the three files into one file. 
  1631.  
  1632.               Compile the file creating the executable file called
  1633.               main2.exe.  Execute main2.exe.
  1634.  
  1635.  
  1636.  
  1637.  
  1638.        22.    COBOL: Copy teacher.cob from teacher.
  1639.  
  1640.               Compile and run.
  1641. 5.  THE make UTILITY 
  1642.  
  1643.  
  1644. The make utility is used to keep a set of executable programs
  1645. current.  This is based on the modification times of the programs
  1646. and the source code that each program is dependent upon.  The
  1647. utility will look at the dependency lines in a file called
  1648. makefile in the current working directory.  These dependency
  1649. lines indicate relationships between files, specifying a target
  1650. file that is dependent on one or more prerequisite files.  If you
  1651. modified any of the prerequisite files more recently than the
  1652. target file, make will update the target file based on
  1653. construction commands that follow the dependency lines.
  1654.  
  1655.  
  1656. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  1657. ”    Command Format: make [options] [target_files]              ”
  1658. ”                                                               ”
  1659. ”    See the online man pages for a detailed list of options    ”
  1660. ”                                                               ”
  1661. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  1662.  
  1663.  
  1664. The target_files refer to targets on dependency lines in the file
  1665. called makefile. If you do not specify a target_file, make will
  1666. update the first dependency line it finds in makefile.
  1667.  
  1668. The makefile has the following construction:
  1669.  
  1670.        target:   prerequisite_list
  1671.        tab       construction_commands
  1672.  
  1673. The dependency line is composed of target and the
  1674. prerequisite_list, separated by a colon.  The
  1675. construction_commands must start with a tab character and must
  1676. follow the dependency line. 
  1677.  
  1678. The target is the name of the file that is dependent on the files
  1679. in the prerequisite_list.  The construction_commands are shell
  1680. commands that construct the target, these are usually compile 
  1681. commands.
  1682.  
  1683. The make utility will execute the construction_commands when the
  1684. modification time  of one or more of the files in the
  1685. prerequisite_list is more recent than the target.
  1686.  
  1687. Sample makefile:
  1688.  
  1689.        payroll: sales.c salary.c
  1690.               cc sales.c salary.c -o payroll
  1691.  
  1692. In the example, the target is called payroll. It is dependent on
  1693. sales.c and salary.c.  If the modification time of either of
  1694. these is more recent than payroll, the construction_commands will
  1695. be executed. In this case, the source code programs are compiled
  1696. and stored in payroll.
  1697.  
  1698. In the previous example, to get the update to occur simply type
  1699. make.
  1700.  
  1701. Example:
  1702.  
  1703. .................................................................
  1704. .    $make                                                      . 
  1705. .................................................................
  1706.                                                                  
  1707. Since no target was specified, the first dependency line is the
  1708. one that make will attempt to execute.
  1709.  
  1710. Each of the prerequisites on one dependency line can be a target
  1711. on other dependency lines.  This nesting of specifications can
  1712. continue, creating a complex hierarchy that can specify a large
  1713. system of programs.
  1714.  
  1715.  
  1716. Sample makefile:
  1717.  
  1718.  
  1719.      form:  size.o length.o
  1720.              cc size.o length.o -o form
  1721.      size.o:  size.c form.h
  1722.              cc -c size.c
  1723.      length.o: length.c form.h
  1724.              cc -c length.c
  1725.      form.h:  num.h table.h
  1726.             cat num.h table.h > form.h
  1727.      
  1728. Notice that form is dependent on two object files, size.o and
  1729. length.o.  These two object files are, in turn, dependent upon
  1730. their respective source code programs and the header file,
  1731. form.h.  The header file is dependent upon two other header
  1732. files.  Note that the construction_commands for form.h can use
  1733. any shell command, in this case cat creates the header file.
  1734. This makefile can be quite difficult to write, especially if
  1735. there are a number of interdependencies.  The make utility can
  1736. rely upon implied dependencies and construction_commands to make
  1737. your job of writing the makefile easier.  If you do not include a
  1738. dependency line for a file, make assumes that object program
  1739. files are dependent on compiler or assembler source code files. 
  1740. If a prerequisite for a target file is <filename>.o and
  1741. <filename>.o is not a target with its own prerequisites, make
  1742. will search for one of the following files in the current working
  1743. directory. 
  1744.  
  1745.        Filename             Type of file
  1746.  
  1747.      <filename>.c          C source code
  1748.      <filename>.f          FORTRAN source code
  1749.      <filename>.s          Assembler source code
  1750.  
  1751. If you do not include a construction_command for one of the files
  1752. listed, make will create a default construction_command line that
  1753. will call the appropriate compiler or assembler to create the
  1754. object file.
  1755. grep: A PATTERN MATCHING FILTER
  1756.  
  1757.  
  1758. The grep utility can search through a file to see if it contains
  1759. a specified string of characters.  The utility will not change
  1760. the  file it searches but displays each line that contains the
  1761. string.  The format for the string is as follows.
  1762.  
  1763.  
  1764. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  1765. ”  Command Format:  grep [options] limited_regular-expression [file]         ”
  1766. ”                                                                            ”
  1767. ”    Use the man command for a complete list of options                      ”
  1768. ”                                                                            ”
  1769. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  1770.  
  1771. The grep utility searches files for a pattern and displays all 
  1772. lines that contain the pattern.  It uses limited-regular-
  1773. expressions (these are expressions that have string values that 
  1774. use a subset of all the possible alphanumeric and special 
  1775. characters) like those used with ed to match the patterns. 
  1776.  
  1777. Be careful using the characters $, *, [, ^, |, (, ), and \ in the
  1778. regular expression because they will be evaluated by the Shell. 
  1779. It is good practice to enclose the regular expression in single 
  1780. quotes.  This will prevent the Shell from evaluating these
  1781. special characters.
  1782.  
  1783. The grep utility will assume standard input if no files are 
  1784. given.  Normally, each line found in the file will be displayed 
  1785. to standard output.
  1786.  
  1787. Sample session:
  1788.  
  1789. .................................................................
  1790. .    $grep 'disc' memo                                          .
  1791. .................................................................
  1792.  
  1793. This command will search the file "memo" for the string "disc".
  1794. It will include words like discover and indiscreet because they
  1795. contain the characters "disc".  The single quote marks are not
  1796. necessary, and for this example, they wouldn't have made any
  1797. difference.  They do allow you to include spaces in the search
  1798. pattern. 
  1799. 5.0.1  More on Regular Expressions
  1800.  
  1801.  
  1802. The grep command can be best understood by a discussion of
  1803. regular expressions.  Let's create a database of phone numbers
  1804. called phone.lis and then use regular expressions to search
  1805. through the database.  Here is as listing of the contents of
  1806. phone.lis
  1807.  
  1808. Sample session:
  1809.  
  1810. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1811. ‡    $cat phone.lis                                             ‡
  1812. ‡    Smith, Joan              7-7989                            ‡
  1813. ‡    Adams, Fran              2-3876                            ‡
  1814. ‡    StClair, Fred            4-6122                            ‡
  1815. ‡    Jones, Ted               1-3745                            ‡
  1816. ‡    Stair, Rich              5-5972                            ‡
  1817. ‡    Benson, Sam              4-5587                            ‡
  1818. ‡    $                                                          ‡
  1819. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1820.  
  1821. The format for the records in this database is:
  1822.                                              
  1823.        Last name, First name <tab>   #-####
  1824.  
  1825. Using the database (phone.lis) above.  What grep command would we
  1826. use to search through the database and get all the records that
  1827. had a person whose name contains an "S".
  1828.  
  1829. An alphabetic character represents itself.
  1830.  
  1831. Sample session:
  1832.  
  1833. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1834. ‡    $grep S phone.lis                                          ‡
  1835. ‡    Smith, Joan              7-7989                            ‡
  1836. ‡    StClair, Fred            4-6122                            ‡
  1837. ‡    Stair, Rich              5-5972                            ‡
  1838. ‡    Benson, Sam              4-5587                            ‡
  1839. ‡    $                                                          ‡
  1840. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1841.  
  1842. This grep command searched for the string "S" and then listed all
  1843. the lines in phone.lis that matched.
  1844. A single . (dot) is used to represent any single character.
  1845.  
  1846. Sample session:
  1847.  
  1848. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1849. ‡    $grep .S phone.lis                                         ‡
  1850. ‡    Benson, Sam         4-5587                                 ‡
  1851. ‡    $                                                          ‡
  1852. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1853.  
  1854. A $ represents the end of the line.
  1855.  
  1856. Sample session:
  1857.  
  1858. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1859. ‡    $grep 5$ phone.lis                                         ‡
  1860. ‡    Jones, Ted         1-3745                                  ‡
  1861. ‡    $                                                          ‡
  1862. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1863.  
  1864. A ^ represents the beginning of the line
  1865.  
  1866. Sample session:
  1867.  
  1868. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1869. ‡    $grep ^S phone.lis                                         ‡
  1870. ‡    Smith, Joan         7-7989                                 ‡
  1871. ‡    StClair, Fred       4-6122                                 ‡
  1872. ‡    Stair, Rich         5-5972                                 ‡
  1873. ‡    $                                                          ‡
  1874. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1875.  
  1876. Regular expressions must get to grep in order for them to be
  1877. evaluated properly.  Let's say we want to get the records of
  1878. employees that have a phone number that begins with a "4".
  1879.  
  1880. What does the following expression do?
  1881.  
  1882. Sample session:
  1883.  
  1884. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1885. ‡    $grep <tab>4 phone.lis                                     ‡
  1886. ‡    StClair, Fred        4-6122                                ‡
  1887. ‡    Jones, Ted           1-3745                                ‡
  1888. ‡    Benson, Sam          4-5587                                ‡
  1889. ‡    $                                                          ‡
  1890. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1891.  
  1892. Why did we get the record of Ted Jones?  The tab character was 
  1893. evaluated by the Shell and so the search was actually made
  1894. looking for a "4".  This is the same as if we had entered $grep 4
  1895. phone.lis.
  1896. We must prevent the Shell from evaluating these characters, this
  1897. is done with the \ (backslash) character as shown in the next
  1898. example.
  1899.  
  1900. Sample session:
  1901.  
  1902. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1903. ‡    $grep \<tab>4 phone.lis                                    ‡
  1904. ‡    StClair, Fred                4-6122                        ‡
  1905. ‡    Benson, Sam                  4-5587                        ‡
  1906. ‡    $                                                          ‡
  1907. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1908.  
  1909. Now it worked properly.  It searched for a <tab> character       
  1910. followed by the number 4.  The [] (left and right brackets) are
  1911. used to identify a range of characters.
  1912.  
  1913. Sample session:
  1914.  
  1915. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1916. ‡    $grep \[AF] phone.lis                                      ‡
  1917. ‡    Adams, Fran             2-3876                             ‡
  1918. ‡    StClair, Fred           4-6122                             ‡
  1919. ‡    $                                                          ‡
  1920. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1921.  
  1922. Why do [] need to be quoted?  In the previous example the search 
  1923. makes a match on "A" or "F". 
  1924.  
  1925. A - (dash) can indicate inclusion.  For example, we want to make
  1926. a match on a phone number that has a 1, 2, 3, or 4.  How can this
  1927. be done?  Here's an example:
  1928.  
  1929. Sample Session:
  1930.  
  1931. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1932. ‡    $grep \[1-4] phone.lis                                     ‡
  1933. ‡    Adams, Fran                2-3876                          ‡
  1934. ‡    StClair, Fred              4-6122                          ‡
  1935. ‡    Jones, Ted                 1-3745                          ‡
  1936. ‡    Stair, Rich                5-5972                          ‡
  1937. ‡    Benson, Sam                4-5587                          ‡
  1938. ‡    $                                                          ‡
  1939. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1940.  
  1941. A ^ character looks for all characters NOT inside the []
  1942. brackets. 
  1943.  
  1944. For example,
  1945.  
  1946.        [^0-9]        matches all non-digits
  1947.  
  1948.        [^a-zA-Z]     matches all non-alphabetic characters
  1949.  
  1950.        NOTE:         \, *, and $ lose their metacharacter meanings
  1951.                      inside the [].  Also the ^ character is special
  1952.                      only if it appears first.
  1953.  
  1954. What is the following command searching for?
  1955.  
  1956. Sample Session:
  1957.  
  1958. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1959. ‡    $grep '[^789]$' phone.lis                                  ‡
  1960. ‡    Adams, Fran                  2-3876                        ‡
  1961. ‡    StClair, Fred                4-6122                        ‡
  1962. ‡    Jones, Ted                   1-3745                        ‡
  1963. ‡    Stair, Rich                  5-5972                        ‡
  1964. ‡    $                                                          ‡
  1965. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1966.                                                                  
  1967. 5.0.2  Still More Regular Expressions
  1968.  
  1969.  
  1970. The * (asterisk) represents zero or more of the characters
  1971. preceding the asterisk.
  1972.  
  1973.        A*            represents 0 or more As.
  1974.  
  1975.        AA*           represents 1 or more As.
  1976.  
  1977.        [0-9]*$       0 or more digits at the end of a line 
  1978.                      (last four digits in a phone number)
  1979.  
  1980.        .*            represents 0 or more of any character.
  1981.  
  1982.  
  1983. How would you write a grep command using regular expressions to
  1984. find the last name starting with an "S" and the first name with
  1985. an "F"?
  1986.  
  1987.  
  1988.        ^S            Begins with an "S"
  1989.  
  1990.        .*,F          Any number of characters before ,F
  1991.  
  1992. Sample session:
  1993.  
  1994. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1995. ‡    $grep ^S.\*,F phone.lis                                    ‡
  1996. ‡    StClair, Fred     4-6122                                   ‡
  1997. ‡    $                                                          ‡
  1998. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1999.                                                                  
  2000. NOTE:         The * (asterisk) was quoted so the Shell didn't try to
  2001.               evaluate it.
  2002.  
  2003. It is very desirable to quote the entire string to keep the Shell
  2004. from doing an expansion or substitution.  It also increases
  2005. readability of the regular expression as in the following
  2006. example.
  2007.  
  2008. Sample session:
  2009.  
  2010. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2011. ‡    $grep '^S.*, F' phone.lis                                  ‡
  2012. ‡    StClair, Fred     4-6122                                   ‡
  2013. ‡    $                                                          ‡
  2014. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2015. 5.0.3  Some Nice grep Options             
  2016.  
  2017.  
  2018. The grep provides several options that modify how the search is
  2019. performed.
  2020.  
  2021.        -c     Report count of matching lines only
  2022.  
  2023.        -v     Print those lines that don't match the pattern.
  2024.  
  2025. What will these lines print?
  2026.  
  2027. Sample session:
  2028.  
  2029. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2030. ‡     $grep -c '[J-Z]' phone.lis                                ‡
  2031. ‡     5                                                         ‡
  2032. ‡     $                                                         ‡
  2033. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2034.                                                                  
  2035. Why did we get this result?  Let's analyze the command.  In 
  2036. English, this command could be interpreted to mean "Tell me how
  2037. many records in the file "phone.lis" contain a letter from the
  2038. set J through and including Z."  Look at the phone.lis file and
  2039. see that five records fit this restriction.  So the answer is 5.
  2040.  
  2041. Now look at another example and see what this one does.
  2042.  
  2043. Sample session:
  2044.  
  2045. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2046. ‡    $grep -v '[J-Z]' phone.lis                                 ‡
  2047. ‡    Adams,Fran        2-3876                                   ‡
  2048. ‡    $                                                          ‡
  2049. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2050.  
  2051. Why is this the only record that was found?  The -v option says
  2052. to select records that don't match the pattern.  This is the same
  2053. pattern as the previous example and therefore it selects records
  2054. that don't match the pattern.  The "Adams" record is the only one
  2055. that doesn't make a match.  It doesn't have a character from the
  2056. set J through and Z.
  2057. 5.0.4  Summary of Regular Expression Characters
  2058.  
  2059.  
  2060.        ^             Beginning of the line
  2061.  
  2062.        $             End of the line
  2063.  
  2064.        *             0 or more preceding characters
  2065.  
  2066.        .             Any single character
  2067.  
  2068.        [...]         A range of characters
  2069.  
  2070.        [^...]        Exclusion range of characters
  2071.  
  2072.  
  2073.  
  2074. sed: EDIT A FILE TO STANDARD OUTPUT
  2075.  
  2076.  
  2077. UNIX provides a method of editing streams of data.  It is the sed
  2078. utility.  The name of this utility is derived from Stream EDitor.
  2079. This is not the same as the vi editor.  The vi editor edits text
  2080. in a file.  The sed utility edits text in a stream.  In order to
  2081. edit a character stream two things are required.  First, the line
  2082. to edit must be identified (regular expressions) and second, how
  2083. to edit the line.
  2084.  
  2085. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2086. ”    Command Format: sed [-n] [-e script] [-f sfile] [files]    ”
  2087. ”                                                               ”
  2088. ”    Details in on-line man pages                               ”
  2089. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2090.  
  2091. The sed utility copies the named files (standard input default)
  2092. to the standard output, edited according to a set (script) of
  2093. commands.  The -f options cause the script to be taken from file
  2094. "sfile".
  2095.  
  2096. The general form is:
  2097.  
  2098.        $sed /address/instruction
  2099.  
  2100. NOTE:         If no address is specified, all lines are chosen to
  2101.               edit.
  2102.  
  2103.  
  2104. 'sed' addresses can be line numbers or regular expressions.
  2105.  
  2106. Example:
  2107.  
  2108.        line numbers                2,4
  2109.                                    2,$    ($ represents the last line)
  2110.  
  2111.        textual address             /regular-expression/
  2112.  
  2113.  
  2114.  
  2115. NOTE:         Forward slashes enclose textual addresses
  2116.  
  2117. The sed instructions indicate what editing function to perform.
  2118. Here some useful sed instructions:
  2119.  
  2120.        s             substitute
  2121.  
  2122.        d             delete
  2123.  
  2124. NOTE:         Most sed command lines contain spaces or metacharacters
  2125.               and they should be quoted to protect them from the
  2126.               Shell.  There are many more editing commands provided
  2127.               by sed.  The following is a sample sed command to edit
  2128.               the records in the database file that we are already
  2129.               familiar with; namely, phone.lis.
  2130.  
  2131. Sample session:
  2132.  
  2133. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2134. ‡    $sed /s/Smith/Smythe/ phone.lis                            ‡
  2135. ‡    Smythe, Joan        7-7989                                 ‡
  2136. ‡    Adams, Fran         2-3876                                 ‡
  2137. ‡    StClair, Fred       4-6122                                 ‡
  2138. ‡    Jones, Ted          1-3745                                 ‡
  2139. ‡    Stair, Rich         5-5972                                 ‡
  2140. ‡    Benson, Sam         4-5587                                 ‡
  2141. ‡    $                                                          ‡
  2142. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2143.                                                                  
  2144. sed is an editor.  It simply copies the standard input to the
  2145. standard output, editing the lines that match the indicated
  2146. address.  The original file is not changed. 
  2147.  
  2148. Here's another example of a sed command.
  2149.  
  2150. Sample session:
  2151.  
  2152. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2153. ‡    $sed '2,4 s/2$/3/' phone.lis                               ‡
  2154. ‡    Smith, Joan         7-7989                                 ‡
  2155. ‡    Adams, Fran         2-3876                                 ‡
  2156. ‡    StClair, Fred       4-6123                                 ‡
  2157. ‡    Jones, Ted          1-3745                                 ‡
  2158. ‡    Stair, Rich         5-5972                                 ‡
  2159. ‡    Benson, Sam         4-5587                                 ‡
  2160. ‡    $                                                          ‡
  2161. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2162.  
  2163. What does this sed command do?  If you read command in English it
  2164. reads like this: On lines 2 through 4 substitute the 2 at the end
  2165. of the line with a 3.  Notice that the phone number for 
  2166. StClair, Fred changed from 4-6122 to 4-6123.  The number for
  2167. Stair, Rich didn't change because it was outside the range.
  2168.  
  2169. The sed utility can also be use to delete parts of a line of
  2170. data.  This is done by substituting nothing for the parts you
  2171. want to delete.  It looks like this:
  2172.  
  2173. Sample session:
  2174.  
  2175. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2176. ‡    $sed 's/^.*, //' phone.lis                                 ‡
  2177. ‡    Joan               7-7989                                  ‡
  2178. ‡    Fran               2-3876                                  ‡
  2179. ‡    Fred               4-6122                                  ‡
  2180. ‡    Ted                1-3745                                  ‡
  2181. ‡    Rich               5-5972                                  ‡
  2182. ‡    Sam                4-5587                                  ‡
  2183. ‡    $                                                          ‡
  2184. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2185.  
  2186. Reading this command it means:                                   
  2187.  
  2188. Substitute from the beginning of the line followed by any number
  2189. of characters followed by a comma with the null string (nothing). 
  2190. This has the effect of removing the text.               
  2191.  
  2192. Here's a delete command and how it's used.
  2193.  
  2194. Sample session:
  2195.  
  2196. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2197. ‡    $sed d phone.lis                                           ‡
  2198. ‡    $                                                          ‡
  2199. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2200.  
  2201. Why is there no output? Well, it read standard input and did the
  2202. editing function on all the selected lines.  Since no lines were
  2203. specified all lines were selected to be edited.  The editing was
  2204. to delete the line.
  2205.  
  2206. Question: Has the original file been destroyed?
  2207.  
  2208. Multiple commands are allowed in sed.  Each instruction is
  2209. applied to each input line.
  2210.  
  2211. Sample session:
  2212.  
  2213. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2214. ‡    $sed '/Stair/d                                             ‡
  2215. ‡    >/Adams/d' phone.lis                                       ‡
  2216. ‡    Smith, Joan         7-7989                                 ‡
  2217. ‡    StClair, Fred       4-6122                                 ‡
  2218. ‡    Jones, Ted          2-1136                                 ‡
  2219. ‡    Benson, Sam         4-5587                                 ‡
  2220. ‡    $                                                          ‡
  2221. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2222.  
  2223. The records for Adams and Stair have both been removed from the
  2224. database.
  2225.  
  2226. NOTE:         The > character is the BourneShell secondary prompt.
  2227.  
  2228.  
  2229. awk: A PATTERN MATCHING PROGRAMMING LANGUAGE
  2230.  
  2231.  
  2232. Suppose you wanted to change the format of the database phone.lis
  2233. to be the first name followed by the last name.  There is no easy
  2234. way to do this with sed.  Fortunately, UNIX not only provides a
  2235. stream editor (sed) but it also has a formatting tool.  The
  2236. formatting tool in UNIX is called awk.  This tool is named after
  2237. authors who wrote it  Alfred V. Aho, Peter J. Weinberger, and
  2238. Brian W. Kerninghan so it really doesn't have any meaning.
  2239.  
  2240. The awk utility is a pattern scanning and processing language. 
  2241. It will search one or more files for a specified pattern and then
  2242. performs an action, such as writing to standard output or
  2243. incrementing a counter when it finds a match.  You can use awk to
  2244. generate reports or filter text.  It works equally well with
  2245. numbers or text.  The authors designed it to be easy to use and
  2246. sacrificed execution speed toward this end.
  2247.  
  2248. While the sed utility allows us to change the text in a stream,
  2249. awk allows us to easily rearrange, add, or delete text in a
  2250. stream.
  2251.  
  2252. The awk takes advantage of many constructs from the C programming
  2253. language.  It has the following features:
  2254.  
  2255.  
  2256.        flexible format
  2257.        conditional execution
  2258.        looping statements
  2259.        numeric variables
  2260.        string variables
  2261.        regular expressions
  2262.        C's printf
  2263.  
  2264.  
  2265. The awk will take its input from the files you specify on the
  2266. command line or from standard input.  The following is the format
  2267. for awk:
  2268.  
  2269. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2270. ”    Command format: awk [-Fc] [prog] [files]                   ”
  2271. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2272.  
  2273. The awk will scan each line of file for lines that match a set of
  2274. patterns specified by prog.  With each pattern in prog there can
  2275. be an associated action to be performed when the line is found. 
  2276. The set of patterns may appear literally as prog, or in a file
  2277. specified as -f file.  The prog string should be enclosed in
  2278. single quotes to protect it from the Shell.
  2279.  
  2280. Files are read in order and if there are none specified the
  2281. standard input is read.  Each line is matched against the pattern
  2282. portion of every pattern-action statement.  The associated action
  2283. is performed for each matched pattern.  An input line is made up
  2284. fields separated by white space.  $1, $2.. define the fields.  $0
  2285. refers to the whole line.
  2286.  
  2287. A pattern-action statement has the form:
  2288.  
  2289.  
  2290.        pattern {action}
  2291.  
  2292.  
  2293. A missing action means print the line; a missing pattern always
  2294. makes a match.  A statement can be one of the following:
  2295.  
  2296.  
  2297.        if (conditional) statement [else statement]
  2298.        while (conditional) statement
  2299.        for (expression;conditional;expression) statement
  2300.        break
  2301.        continue
  2302.        {[statement]...}
  2303.        variable=expression
  2304.        print [expression-list] [>expression]
  2305.        printf format [,expression-list][>expression]
  2306.        next # skip remaining pattern on this input line
  2307.        exit # skip the rest of the input
  2308.  
  2309.  
  2310. Statements are terminated by semicolons, new lines (Ret), or
  2311. right braces.
  2312.  
  2313. Let's look at the syntax for awk in a little simpler manner.
  2314.  
  2315.  
  2316.        awk 'commands' [filename]
  2317.  
  2318.  
  2319. An awk program (commands) consists of a optional pattern to match
  2320. and an action to perform if a match is found on the current line. 
  2321. This syntax looks like this:
  2322.  
  2323.  
  2324.        awk '/pattern/{action}' [filename]
  2325. The pattern used is a regular expression enclosed in forward
  2326. slashes.  If no pattern is listed, the action will be performed
  2327. for every line.  An action can contain several commands.  There
  2328. can be multiple patterns and actions.
  2329.  
  2330.        awk '/pattern1/{action1}
  2331.        /pattern2/{action2}' [filename}
  2332.  
  2333.  
  2334. One of awk's commands is print.  It puts the current line on
  2335. standard output.
  2336.  
  2337. Sample session:
  2338.  
  2339. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2340. ‡   $awk '{print}' phone.lis                                    ‡
  2341. ‡   Smith, Joan         7-7989                                  ‡
  2342. ‡   Adams, Fran         2-3876                                  ‡
  2343. ‡   StClair, Fred       4-6122                                  ‡
  2344. ‡   Jones, Ted          1-3745                                  ‡
  2345. ‡   Stair, Rich         5-5972                                  ‡
  2346. ‡   Benson, Sam         4-5587                                  ‡
  2347. ‡   $                                                           ‡
  2348. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2349.  
  2350. The awk splits every input line at whitespace and keeps track of
  2351. the number of fields on each line and counts the number of lines
  2352. read.  Each field is identified by its field number and a $.
  2353.  
  2354.        $1     Identifies the first field
  2355.  
  2356.        $2     Identifies the second field
  2357.  
  2358.        .
  2359.  
  2360.        $0     Identifies the entire line
  2361.  
  2362.        NF     Identifies the number of fields on the line
  2363.  
  2364.        NR     Identifies the number of lines that have been read
  2365. Sample session:
  2366.  
  2367. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2368. ‡    $awk '{print NR,$1}' phone.lis                             ‡
  2369. ‡    1 Smith,                                                   ‡
  2370. ‡    2 Adams,                                                   ‡
  2371. ‡    3 StClair,                                                 ‡
  2372. ‡    4 Jones,                                                   ‡
  2373. ‡    5 Stair,                                                   ‡
  2374. ‡    6 Benson,                                                  ‡
  2375. ‡    $                                                          ‡
  2376. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2377.  
  2378. To change the order of the names in phone.lis, use awk.  The
  2379. comma in the print command tells awk to separate each field with
  2380. a space.  Without the comma, the output would have no spacing.
  2381.  
  2382. Sample session:
  2383.  
  2384. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2385. ‡    $awk '{print $2, $1 "<tab>"$3}' phone.lis                  ‡
  2386. ‡    Joan Smith,        7-7989                                  ‡
  2387. ‡    Fran Adams,        2-3876                                  ‡
  2388. ‡    Fred StClair,      4-6122                                  ‡
  2389. ‡    Ted Jones,         1-3745                                  ‡
  2390. ‡    Rich Stair,        5-5972                                  ‡
  2391. ‡    Sam Benson,        4-5587                                  ‡
  2392. ‡    $                                                          ‡
  2393. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2394.  
  2395. sort: SORT A FILE
  2396.  
  2397.  
  2398. The sort utility sorts line of all the named files together and
  2399. writes the result to standard output.  The standard input is used
  2400. if - is used as a file name or no input files are specified.
  2401.  
  2402. Comparisons are based one or more sort keys extracted from each
  2403. line of input.  There is only one key by default, that's the
  2404. entire line, and ordering is lexicographic by bytes in machine
  2405. collating sequence.
  2406.  
  2407. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2408. ”    Command format: sort [-cmu][-ooutput][-ykmem][-zrecsz]     ”
  2409. ”                         [-dfiMnr][-btx][+pos][-pos2][files]   ”
  2410. ”                                                               ”
  2411. ”     See on-line manual for options etc.                       ”
  2412. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2413.  
  2414. The easiest way to use sort is to add it at the end af a
  2415. pipeline.  What does the following command line accomplish:
  2416.  
  2417. Sample session:
  2418.  
  2419. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2420. ‡   $grep '<tab>[45]' phone.lis | sed 's/<tab>/<tab>73/' | sort ‡
  2421. ‡   Benson, Sam         734-5587                                ‡
  2422. ‡   StClair, Fred       734-6122                                ‡
  2423. ‡   Stair, Rich         735-5972                                ‡
  2424. ‡   $                                                           ‡
  2425. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2426.  
  2427. The grep command will select only those records that have a 4 of 
  2428. a 5 in the phone number, those records are then sent to sed which
  2429. will add "73" just after the tab character, then the records are
  2430. sent to sort and put in alphabetical order.  Notice that there is
  2431. a problem here, should StClair come before Stair in an
  2432. alphabetical listing?  The answer is NO.  Why did this happen? 
  2433. It occurred because of the collating sequence for the default
  2434. sort.
  2435. This can be fixed by specifying some options on the call to the
  2436. sort utility.  Here are some options for sort.  Let's see if we
  2437. can determine how to remedy the problem discovered in the default
  2438. sort.
  2439.  
  2440. sort options:
  2441.  
  2442.        -f     Fold lower case into upper case
  2443.        -r     Reverse the sort from highest to lowest
  2444.        -b     Ignore leading blank spaces
  2445.        -d     Dictionary sort - ignore nonalphanumeric characters
  2446.        -m     Merge two sorted files together
  2447.        -n     Sort the list as numbers not digit characters
  2448.  
  2449. Notice the -f options folds lower case into upper case.  This
  2450. option will make the sort for our problem work correctly.
  2451.  
  2452. Sample session:
  2453.  
  2454. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2455. ‡ $grep '<tab>[45]' phone.lis|sed 's/<tab>/<tab>73/'|sort -f    ‡
  2456. ‡   Benson, Sam         734-5587                                ‡
  2457. ‡   Stair, Rich         735-5972                                ‡
  2458. ‡   StClair, Fred       734-6122                                ‡
  2459. ‡   $                                                           ‡
  2460. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2461.  
  2462. The sort can also be directed to use only a portion of the line
  2463. as a sorting key versus the entire line.  The utility will
  2464. automatically break each line into fields at whitespace
  2465. delimiters.  You can use a character other than whitespace by
  2466. using the -t option.  The fields are set up like this:
  2467.  
  2468.  
  2469.         0     1        2
  2470.       /----|/---|/-------------|
  2471.        Adams, Fran         2-3876
  2472. In order to sort by the second field, here is the sort command to
  2473. enter.
  2474.  
  2475. Sample session:
  2476.  
  2477. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2478. ‡    $sort +1 phone.lis                                         ‡
  2479. ‡    Adams, Fran        2-3876                                  ‡
  2480. ‡    StClair, Fred      4-6122                                  ‡
  2481. ‡    Smith, Joan        7-7989                                  ‡
  2482. ‡    Stair, Rich        5-5972                                  ‡
  2483. ‡    Benson, Sam        4-5587                                  ‡
  2484. ‡    Jones, Ted         1-3745                                  ‡
  2485. ‡    $                                                          ‡
  2486. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2487.  
  2488. Here's a sample of a sort on the 3rd field.
  2489.  
  2490. Sample session:
  2491.  
  2492. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2493. ‡     $sort +2 phone.lis                                        ‡
  2494. ‡     Jones, Ted        1-3745                                  ‡
  2495. ‡     Adams, Fran       2-3876                                  ‡
  2496. ‡     Benson, Sam       4-5587                                  ‡
  2497. ‡     StClair, Fred     4-6122                                  ‡
  2498. ‡     Stair, Rich       5-5972                                  ‡
  2499. ‡     Smith, Joan       7-7989                                  ‡
  2500. ‡     $                                                         ‡
  2501. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2502.  
  2503. A sort can also be performed by a character position within a
  2504. field.
  2505.  
  2506. Sample session:
  2507.  
  2508. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2509. ‡    $sort +2.4 phone.lis                                       ‡
  2510. ‡    StClair, Fred           4-6122                             ‡
  2511. ‡    Benson, Sam             4-5587                             ‡
  2512. ‡    Jones, Ted              1-3745                             ‡
  2513. ‡    Adams, Fran             2-3876                             ‡
  2514. ‡    Stair, Rich             5-5972                             ‡
  2515. ‡    Smith, Joan             7-7989                             ‡
  2516. ‡    $                                                          ‡
  2517. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2518.  
  2519. NOTE:         The first character of a field is the delimiter for
  2520.               that field.
  2521. 5.1  ARCHIVER AND LIBRARY MAINTAINER
  2522.  
  2523.  
  2524. This command will maintain groups of files combined into a single
  2525. archive file.  The main use of ar is to create and update library
  2526. files as used by the link editor.  It can also be used for any
  2527. other similar purpose.  The file header consists of printable
  2528. ASCII characters.  If the archive consists of printable
  2529. characters, then the entire archive is also printable.
  2530.  
  2531.                                                                  
  2532. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2533. ” Command Format:  ar key [posname] afile [name]...             ”
  2534. ”                                                               ”
  2535. ” Unlike command options, the command key is required.  The key,”
  2536. ” usually a - sign, is formed with one of the following letters ”
  2537. ” drqtpmx.  Arguments to the key are made from one or more of   ”
  2538. ” the following set, vuaibcis.  See Appendix I for a complete   ”
  2539. ” list of command keys.                                         ”
  2540. ”                                                               ”
  2541. ” posname is an archive member name used as a reference for     ”
  2542. ” positioning other files in the archive.                       ”
  2543. ”                                                               ”
  2544. ” afile is the name of the archive.                             ”
  2545. ”                                                               ”
  2546. ” name[s] are the constituent files in the archive.             ”
  2547. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2548.                                                                
  2549. To illustrate how to create and use an archive file, we will use
  2550. the "C" program called main.c and the two functions, funct1.c and
  2551. funct2.c.   First, create the object files that we intend to put
  2552. into the archive file.
  2553.  
  2554. Sample Session:
  2555.  
  2556. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2557. ‡ $cc -c main.c funct1.c funct2.c                               ‡
  2558. ‡ main.c:                                                       ‡
  2559. ‡ funct1.c:                                                     ‡
  2560. ‡ funct2.c:                                                     ‡
  2561. ‡ $ls -C *.o                                                    ‡
  2562. ‡ funct1.o funct2.o main.o                                      ‡
  2563. ‡ $                                                             ‡
  2564. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2565.  
  2566. Remember the -c option will not produce an executable module, but
  2567. it does create the object modules.  These object modules are file
  2568. files that we will place into an archive.
  2569.  
  2570. 5.2  Creating an Archive File with Object Modules
  2571.  
  2572.  
  2573. In this call to ar, we will use the r command key which will
  2574. replace the named files in the archive.  The v option will give a
  2575. verbose file-by-file description of the making of the new archive
  2576. file.
  2577.  
  2578. Sample Session:
  2579.  
  2580. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2581. ‡ $ar rv functs.a funct1.o funct2.o                             ‡
  2582. ‡ a - funct1.o                                                  ‡
  2583. ‡ a - funct2.o                                                  ‡
  2584. ‡ ar: creating functs.a                                         ‡
  2585. ‡ $                                                             ‡
  2586. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2587.  
  2588. The name of the new archive file is functs.a.  The files that
  2589. have been added to that archive are funct1.o and funct2.o.  The
  2590. file protections for the new archive file are rw-r--r--.
  2591.  
  2592.  
  2593.  
  2594. 5.3  Verifying the Contents of the Archive File
  2595.  
  2596. The key command to list the table of contents is t.  The t
  2597. command will print a table of contents of the archive file.  When
  2598. the v option is used with the t command it will give a long
  2599. listing of all information about the files.
  2600.  
  2601. Sample Session:
  2602.  
  2603. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2604. ‡ $ar tv functs.a                                               ‡
  2605. ‡ rw-r--r--    115/    200 448 Sep 27 09:56 1990 funct1.o       ‡
  2606. ‡ rw-r--r--    115/    200 448 Sep 27 09:56 1990 funct2.o       ‡
  2607. ‡ $                                                             ‡
  2608. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2609.  
  2610. This output shows that there are two members in this archive
  2611. file, namely, funct1.o and funct2.o.
  2612.  
  2613. The protections of these files is:
  2614.  
  2615.        owner - read and write
  2616.        group - read
  2617.        other - read
  2618.  
  2619. The fields are, left to right, the file protections, owner,
  2620. group, size (in bytes), creation date and time, and finally the
  2621. name of the constituent.
  2622. 5.4  Removing Duplicate Object Files
  2623.  
  2624.  
  2625. Once the archive has been created and verified, the object files
  2626. in your directory can be deleted.  This can be accomplished with
  2627. the rm command.
  2628.  
  2629. Sample Session:
  2630.  
  2631. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2632. ‡ $rm funct?.o                                                  ‡
  2633. ‡ $                                                             ‡
  2634. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2635.  
  2636. The question mark (?) is a wildcard that stands for any single
  2637. character.  The files funct1.o and funct2.o no longer exist in
  2638. your subdirectory.
  2639.  
  2640.  
  2641.  
  2642. 5.5  Compiling Main and Archive Files
  2643.  
  2644.  
  2645. Now that the object files, funct1.o and funct2.o, are in the
  2646. archive file functs.a you, can link them with main.o in the
  2647. following manner.
  2648.  
  2649. Sample Session:
  2650.  
  2651. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2652. ‡ $cc -o new_hello main.o functs.a                              ‡
  2653. ‡ $ls -la new_hello                                             ‡
  2654. ‡ -rwxr-xr-x  1 teacher class  17570  Sep 27 12:58 new_hello    ‡
  2655. ‡ $                                                             ‡
  2656. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2657. Workshop 5
  2658.  
  2659. This workshop will reinforce your understanding of the ideas
  2660. presented in this chapter.  Login using the username and password
  2661. given to you by the instructor.  Each student is to complete the
  2662. entire workshop.
  2663.  
  2664. DESK EXERCISES 
  2665.  
  2666.  
  2667.  
  2668.        1.     What does the UNIX utility grep do?
  2669.  
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675.  
  2676.  
  2677.        2.     What do the following regular expressions represent?
  2678.  
  2679.  
  2680.                      ^Ba
  2681.  
  2682.  
  2683.  
  2684.                      .*
  2685.  
  2686.  
  2687.  
  2688.                      BB*
  2689.  
  2690.  
  2691.  
  2692.                      J*
  2693.  
  2694.  
  2695.  
  2696.                      [0-9]*$
  2697.  
  2698.  
  2699.               
  2700.        3.     What does the UNIX utility sed do?
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.                                   Continue on the next page
  2709.        4.     What does the UNIX utility awk do?
  2710.  
  2711.  
  2712.  
  2713.  
  2714.  
  2715.  
  2716.        5.     What does the UNIX utility sort do?
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.        6.     What is the main use for the UNIX utility ar?
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.                                   Continue on the next page
  2731.        COMPUTER EXERCISES
  2732.  
  2733.        Use the phone.lis database file to answer the following
  2734.        questions.
  2735.  
  2736.  
  2737.        7.     "I want to find all the phone numbers that begin with a
  2738.                4 and end with a 2"
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.        8.     "I can't remember the name but I believe the last name
  2745.                starts with an S and the first name with an F"
  2746.  
  2747.  
  2748.  
  2749.  
  2750.        9.     Find all the people with 3 character first names.
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.        10.    Write a grep command that finds all the phone numbers
  2757.               that don't begin with a 4, 5, or 6.
  2758.  
  2759.  
  2760.  
  2761.  
  2762.        11.    Write a grep command that finds all entries beginning
  2763.               with J-Z and ending with a 2 or 5.
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.        12.    Put a 23 in front of every phone number.  (Hint:  sed)
  2770.        
  2771.  
  2772.  
  2773.  
  2774.  
  2775.        13.    Replace the first name with the person's first initial
  2776.               and a period.
  2777.  
  2778.  
  2779.  
  2780.  
  2781.  
  2782.                                   Continue on the next page
  2783.        14.    Task:  A new phone system has been installed and people
  2784.               with phone extensions beginning with 4 or 5 now have a
  2785.               new prefix: 73.  Create a file of only the people with
  2786.               the new phone numbers.
  2787.  
  2788.  
  2789.  
  2790.  
  2791.  
  2792.        
  2793.        15.    Print out the phone list showing last name and first                         
  2794.               name in the following format and sorted by last name.
  2795.  
  2796.  
  2797.                                  First name <tab> Last name
  2798.  
  2799.  
  2800.  
  2801.  
  2802.  
  2803.         That's enough, don't you think?
  2804. 6.  UNIX UTILITIES PART I - DISPLAY AND MANIPULATE FILES
  2805.  
  2806.  
  2807. Problem:      I want to know what the differences are between two
  2808.               sorted files.
  2809.  
  2810. Solution:     comm command
  2811.  
  2812.  
  2813. The formal form for the comm command is as follows:
  2814.  
  2815. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2816. ”    Command Format: comm [ - [ 123 ] ] file1 file2             ”
  2817. ”                                                               ”
  2818. ”    Details in on-line man pages                               ”
  2819. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2820.  
  2821. This command will display a line-by-line comparison of two sorted
  2822. files.  The output is divided into three columns.  The first
  2823. column shows the lines only found in the first file, the second
  2824. shows the lines only found in the second file, and the third
  2825. column shows the lines common to both.
  2826.  
  2827.  
  2828. Sample session:
  2829.  
  2830. .................................................................
  2831. .    $comm comm_file1 comm_file2                                .
  2832. .................................................................
  2833.  
  2834. Problem:      I want to store and retrieve files in an archive format 
  2835.               to create backups, transport files to another
  2836.               compatible system or create archives.
  2837.  
  2838. Solution:     cpio command
  2839.  
  2840.  
  2841.  
  2842. The formal form for the cpio utility is as follows:
  2843.                                                                  
  2844. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2845. ”    Command Format: cpio -o[options]                           ”
  2846. ”                                                               ”
  2847. ”                    cpio -i[options] [patterns]                ”
  2848. ”                                                               ”
  2849. ”                    cpio -p[options] directory                 ”
  2850. ”                                                               ”
  2851. ”                                                               ”
  2852. ”    See on line man pages for details on options               ” 
  2853. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2854.                                                                  
  2855.  
  2856. The cpio utility has three functions.  It can copy one or more
  2857. files into a single archive file, retrieve files from a
  2858. previously created archive file, or it can copy directories.  The
  2859. three major options are:
  2860.  
  2861.  
  2862.        -o     (out)         This option will cause cpio to read standard
  2863.                             input to get pathnames of plain files.  It
  2864.                             combines these along with header info into a
  2865.                             single archive file that it copies to
  2866.                             standard output.
  2867.  
  2868.        -i     (in)          This option will read standard input (which
  2869.                             must have been created with the -o option). 
  2870.                             It extracts files  based on patterns you
  2871.                             provide as arguments.
  2872.  
  2873.        -p   (pass)          This option causes cpio to read its standard
  2874.                             input to obtain a list of filenames.  It
  2875.                             copies these files to a directory you
  2876.                             specify.
  2877. Problem:      I have two files and I want to know the differences
  2878.               between them.
  2879.  
  2880. Solution:     diff command
  2881.  
  2882.  
  2883.  
  2884. The formal form for the diff command is as follows:
  2885.  
  2886. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2887. ”    Command Format: diff [options] file1 file2                 ”
  2888. ”                                                               ”
  2889. ”    See online man pages for details                           ”
  2890. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2891.  
  2892.  
  2893. This command will display the differences between two files on a
  2894. line-by-line basis.  The differences are displayed as commands
  2895. you can use to make the two files equal.
  2896.  
  2897. Sample session:
  2898. .................................................................
  2899. .    $diff diff_file1 diff_file2                                .
  2900. .................................................................
  2901.  
  2902. Problem:      I can't remember the name of a file but I know it is in
  2903.               a specific subdirectory and I do know some of its
  2904.               attributes.
  2905.  
  2906. Solution:     find command
  2907.  
  2908.  
  2909.  
  2910. The formal form for the find command is as follows:
  2911.  
  2912. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2913. ”    Command Format: find directory_list expression             ”
  2914. ”                                                               ”
  2915. ”    See online man pages for details                           ”
  2916. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2917.  
  2918. The directory_list contains the pathnames of a directory or
  2919. directories that find will search.  The expression contains one
  2920. or more search criteria.  The utility will test each of the files
  2921. in the directory_list to see if meets the criteria described by
  2922. the expression.
  2923.  
  2924.  
  2925. Sample session:
  2926.  
  2927. .................................................................
  2928. .    $find . -name 'm* ' -print                                 .
  2929. .................................................................
  2930.  
  2931. Problem:      I want a file that exists in another users directory to 
  2932.               appear in my directory listing.
  2933.  
  2934. Solution:     Create a link to that file using the ln command
  2935.  
  2936.  
  2937.  
  2938.  
  2939. The formal form for the ln command is as follows:
  2940.  
  2941. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2942. ”    Command Format: ln existing_file new_link                  ”
  2943. ”                                                               ”
  2944. ”                    ln existing_file_list directory            ”
  2945. ”                                                               ”
  2946. ”    See the online man pages for details                       ”
  2947. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2948.  
  2949. The existing_file is the pathname to the file you want to make a
  2950. link to.  The new_link is the pathname to the new link.  The
  2951. second format allows existing_file_list entries which are
  2952. pathnames that you want links to, they will appear in directory.
  2953. Problem:      I want to see contents of a file displayed in octal
  2954.               format.
  2955.  
  2956. Solution:     Use the od command to display the file in the selected 
  2957.               format. 
  2958.  
  2959.  
  2960.  
  2961. The formal form for the od command is as follows:
  2962.  
  2963. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2964. ”    Command Format: od [options] filename                      ”
  2965. ”                                                               ”
  2966. ”    See online man pages for details                           ”
  2967. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2968.  
  2969. This command is useful for viewing executable (object) files and
  2970. text files with embedded nonprinting characters.  The dump can be
  2971. shown in octal (default) or hexadecimal or character or decimal.
  2972. The name od is short for octal dump.
  2973.  
  2974. Sample session:
  2975.  
  2976. .................................................................
  2977. .    $od -c memo                                                .
  2978. .................................................................
  2979.  
  2980. Problem:      I want to print and format the contents of a specific
  2981.               file.
  2982.  
  2983. Solution:     pr command.
  2984.  
  2985.  
  2986.  
  2987. The formal form for the pr command is as follows:
  2988.  
  2989. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2990. ”    Command Format: pr [options] file_list                     ”
  2991. ”                                                               ”
  2992. ”    See the online man pages for details                       ”
  2993. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2994.  
  2995. This command will break up files into pages, usually before
  2996. printing.  Each page will have a header with the name of the
  2997. file, date, time, and page number.  Usually the output if pr is
  2998. piped to lp so the file can be printed.
  2999.  
  3000. Sample session:
  3001.  
  3002. .................................................................
  3003. .    $pr memo | lp                                              .
  3004. .................................................................
  3005.  
  3006. Problem:      I just wrote a memo and I want to check for mis-spelled 
  3007.               words.
  3008.  
  3009. Solution:     spell command
  3010.  
  3011.  
  3012.  
  3013.  
  3014. The formal form for the spell command is as follows:
  3015.  
  3016. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3017. ”    Command Format: spell [options] file_list                  ”
  3018. ”                                                               ”
  3019. ”    See online man pages for details                           ”
  3020. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3021.  
  3022. The spell command will display all words that are not in the
  3023. dictionary or that can be derived from those words.  You can
  3024. specify more than one file but only one list of misspelled words
  3025. will be shown.
  3026.  
  3027. Sample session:
  3028.  
  3029. .................................................................
  3030. .    $spell memo                                                .
  3031. .................................................................
  3032.  
  3033. Problem:      I want to write a file to tape and later retrieve it
  3034.               back into my directory.
  3035.  
  3036. Solution:     tar command
  3037.  
  3038.  
  3039.  
  3040. The formal form for the tar command is as follows:
  3041.  
  3042. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3043. ”    Command Format: tar key[options] [file_list]               ”
  3044. ”                                                               ”
  3045. ”    See online man pages for details                           ”
  3046. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3047.  
  3048. This command can create, add to, list, or retrieve files from an
  3049. archive file.  The archive file is usually stored on tape.  The
  3050. name tar is short for tape archive.
  3051. Problem:      How many lines are in this file? How many words are in 
  3052.               this file?  How many characters are in this file?
  3053.  
  3054. Solution:     wc command
  3055.  
  3056.  
  3057.  
  3058. The formal form for the wc utility is as follows:
  3059.  
  3060. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3061. ”    Command Format: wc [-lwc] filename                         ”
  3062. ”                                                               ”
  3063. ”    See online man pages for details                           ”
  3064. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3065.  
  3066.  
  3067. Sample session:
  3068.  
  3069. .................................................................
  3070. .    $wc memo                                                   .
  3071. .................................................................
  3072. 7.  UNIX UTILITIES PART II - DISPLAY AND ALTER STATUS
  3073.  
  3074.  
  3075. Problem:      I want to change the group for a particular file so
  3076.               users outside my group can have access.
  3077.  
  3078. Solution:     chgrp command
  3079.  
  3080.  
  3081.  
  3082. The formal form for the chgrp command is as follows:
  3083.  
  3084. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3085. ”    Command Format: chgrp group file_list                      ”
  3086. ”                                                               ”
  3087. ”    See online man pages for details                           ”
  3088. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3089.  
  3090. Sample session:
  3091.  
  3092. .................................................................
  3093. .    $chgrp class memo                                          .
  3094. .................................................................
  3095.  
  3096. Problem:      I want to transfer ownership of a file to another user.
  3097.  
  3098. Solution:     chown command
  3099.  
  3100.  
  3101.  
  3102. The formal form for the chown command is as follows:
  3103.  
  3104. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3105. ”    Command Format: chown owner file_list                      ”
  3106. ”                                                               ”
  3107. ”    See the online man pages for details                       ”
  3108. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3109.  
  3110.  
  3111. The chown command is short for change owner.  Only the owner or
  3112. Superuser can change the ownership of a file. 
  3113.  
  3114.  
  3115. Example:
  3116.  
  3117. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3118. ‡    $chown rharding /u/do/teacher/memo                         ‡
  3119. ‡    $                                                          ‡
  3120. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3121.  
  3122. The file /u/do/teacher/memo is now owned by the username
  3123. rharding.
  3124.  
  3125. Problem:      How can I find out how much space I have left on my
  3126.               disk partition?
  3127.  
  3128. Solution:     df command
  3129.  
  3130.  
  3131.  
  3132. The formal form for the df command is as follows:
  3133.  
  3134. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3135. ”    Command Format: df [options] [file_system_list]            ”
  3136. ”                                                               ”
  3137. ”    See the online man pages for details                       ”
  3138. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3139.  
  3140.  
  3141. The df (disk free) command will show how much free space is
  3142. remaining on any mounted device or directory.  The amount of
  3143. space left is usually displayed in blocks.  Each block is 1024
  3144. bytes in length.
  3145.  
  3146. Sample session:
  3147.  
  3148. .................................................................
  3149. .    $df                                                        .
  3150. .................................................................
  3151.  
  3152. Problem:      How much space does this file occupy on the disk?
  3153.  
  3154. Solution:     du command
  3155.  
  3156.  
  3157.  
  3158. The formal form for the du command is as follows:
  3159.  
  3160. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3161. ”    Command Format: du [options] [file_list]                   ”
  3162. ”                                                               ”
  3163. ”    See the online man pages for details                       ”
  3164. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3165.  
  3166. The du (disk usage) command reports how much space a directory
  3167. and all its subdirectories occupy.  It tells the size in blocks,
  3168. usually 1024 bytes each.
  3169.  
  3170.  
  3171. Sample session:
  3172.  
  3173. .................................................................
  3174. .    $du -s                                                     .
  3175. .    472 .                                                      .
  3176. .    $                                                          .
  3177. .................................................................
  3178.  
  3179. Problem:      I started a process that I don't need anymore.  How can
  3180.               I get rid of it?
  3181.  
  3182. Solution:     kill it with the kill command
  3183.  
  3184.  
  3185.  
  3186. The formal form for the kill command is as follows:
  3187.  
  3188. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3189. ”    Command Format: kill [option] PID_list                     ”
  3190. ”                                                               ”
  3191. ”    See the online man pages for details                       ”
  3192. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3193.  
  3194.  
  3195.  
  3196. The kill command can stop a process by sending a software
  3197. termination signal (number 15) to a process.  The process being
  3198. killed must belong to the user of the kill command.  The
  3199. Superuser can, however, kill any process.  A message will be
  3200. displayed indicating that the process was killed.
  3201.  
  3202.  
  3203. Sample session:
  3204.  
  3205. .................................................................
  3206. .    $compute &                                                 .
  3207. .    1742                                                       .
  3208. .    $kill 1742                                                 .
  3209. .................................................................
  3210.  
  3211. Problem:      There are some files I need access to but they are in 
  3212.               another group. How can I get access to them?
  3213.  
  3214. Solution:     newgrp command
  3215.  
  3216.  
  3217.  
  3218. The formal form for the newgrp command is as follows:
  3219.  
  3220. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3221. ”    Command Format: newgrp [group]                             ”
  3222. ”                                                               ”
  3223. ”    See online man pages for details                           ”
  3224. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3225.  
  3226. This command will fork a new Shell and while in that Shell you
  3227. have the privileges of the group you named on the command line.
  3228. In order for you to use this command you must be listed in the
  3229. /etc/group file as a member of the group.  If you don't specify a
  3230. group it will change you back to the default as specified in the
  3231. /etc/passwd file.
  3232.  
  3233.  
  3234. Sample session:
  3235.  
  3236. .................................................................
  3237. .    $newgrp pubs                                               .
  3238. .................................................................
  3239.  
  3240. Problem:      This job can be run at a lower priority than default. 
  3241.               I want to be a good user and lower the priority so the
  3242.               system can run more efficiently.  Can I do that?
  3243.  
  3244. Solution:     nice command
  3245.  
  3246.  
  3247.  
  3248.  
  3249. The formal form for the nice command is as follows:
  3250.  
  3251. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3252. ”    Command Format: nice [option] command_line                 ”
  3253. ”                                                               ”
  3254. ”    See the online man pages for details                       ”
  3255. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3256.  
  3257.  
  3258. This command will execute the command line at a lower priority
  3259. than normal.  You can specify a range from 1-19.  Sorry, only the
  3260. Superuser can raise the priority.
  3261.  
  3262.  
  3263. Sample session:
  3264.  
  3265. .................................................................
  3266. .    $nice -19 nroff -m chapter1 > chapter1.out &               .
  3267. .................................................................
  3268.  
  3269. Problem:      I want the following command to run to completion even
  3270.               after I logout of the system.  Is that possible?
  3271.  
  3272. Solution:     nohup command
  3273.  
  3274.  
  3275.  
  3276.  
  3277. The formal form for the nohup command is as follows:
  3278.  
  3279. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3280. ”    Command Format: nohup command_line                         ”
  3281. ”                                                               ”
  3282. ”    See the online man pages for details                       ”
  3283. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3284.  
  3285. This command will allow the command that was started to continue
  3286. running even though you logout.  Normally when you logout, all
  3287. processes that you started are killed by the system.
  3288.  
  3289.  
  3290. Sample session:
  3291.  
  3292. .................................................................
  3293. .    $nohup nroff -m memo > memo.out &                          .
  3294. .................................................................
  3295.  
  3296. Note that this process was started in the background.
  3297.  
  3298. Problem:      What is the status of the process I just started?
  3299.  
  3300. Solution:     ps command
  3301.  
  3302.  
  3303.  
  3304.  
  3305. The formal form for the ps command is as follows:
  3306.  
  3307. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3308. ”    Command Format: ps [options]                               ”
  3309. ”                                                               ”
  3310. ”    See the online man pages for details                       ”
  3311. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3312.  
  3313. With no options specified, ps will display the status of all
  3314. active processes that your terminal controls. 
  3315.  
  3316. Problem:      I want to make my process inactive for a few minutes so
  3317.               the user can read the screen before continuing.
  3318.  
  3319. Solution:     sleep command
  3320.  
  3321.  
  3322.  
  3323.  
  3324. The formal form for the sleep command is as follows:
  3325.  
  3326. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3327. ”    Command Format: sleep time                                 ”
  3328. ”                                                               ”
  3329. ”    See the online man pages for details                       ”
  3330. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3331.  
  3332. The sleep command will cause the process executing it to sleep
  3333. for the time you specify.  The time is indicated in seconds.  It
  3334. must be less than 65,536.
  3335.  
  3336. Problem:      I have just logged into a different terminal than I
  3337.               normally use.  It doesn't act right.  How can I change
  3338.               the attributes for my new terminal?
  3339.  
  3340. Solution:     stty command
  3341.  
  3342.  
  3343.  
  3344.  
  3345. The formal form for the stty command is as follows:
  3346.  
  3347. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3348. ”    Command Format: stty [arguments]                           ”
  3349. ”                                                               ”
  3350. ”    See the online man pages for details                       ”
  3351. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3352.  
  3353.  
  3354. With no arguments, stty will report certain parameters affecting
  3355. the operation of your terminal.  The mode of data transmission,
  3356. the treatment of characters, the data line specification, and
  3357. transmission delays can all be set to different values.
  3358. Problem:      I don't like the default protections for files that I
  3359.               create using the editor.  How can I change the default
  3360.               so my files can't be read by others outside my group?
  3361.  
  3362. Solution:     umask command
  3363.  
  3364.  
  3365.  
  3366.  
  3367. The formal form for the umask command is as follows:
  3368.  
  3369. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3370. ”    Command Format: umask [mask]                               ”
  3371. ”                                                               ”
  3372. ”    See the online man pages for details                       ”
  3373. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3374.  
  3375. This command will specify the mask that will be used by the
  3376. system to set the file protections when you create a file.  Mask
  3377. is a three digit octal number.  When you create a file the system
  3378. will subtract these numbers from the system defined protections
  3379. and the resultant protection will be assigned to the newly
  3380. created file.
  3381. 8.  UNIX UTILITIES PART III - MISCELLANEOUS
  3382.  
  3383.  
  3384. Problem:      I just wrote a BourneShell script and I want it to
  3385.               execute once a week at midnight.  Can this be done in
  3386.               UNIX?
  3387.  
  3388. Solution:     at command
  3389.  
  3390.  
  3391.  
  3392.  
  3393. The formal form for the at command is as follows:
  3394.  
  3395.  
  3396. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3397. ”      Command Format:  at time [date] [+ increment]            ”
  3398. ”                                                               ”
  3399. ”                       at [options] job_list                   ”
  3400. ”                                                               ”
  3401. ”      See the online man pages for details                     ”
  3402. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3403.  
  3404. The at command causes the system to execute commands it gets from
  3405. standard input.  It executes them as a Shell script in the
  3406. working directory at a time you specify.
  3407.  
  3408.  
  3409. Sample session:
  3410.  
  3411. .................................................................
  3412. .    $at 2am                                                    .
  3413. .    pr long_file | lp                                          .
  3414. .    Ctrl-d                                                     .
  3415. .    job 474285699.a at Fri Jan 11 02:00:00 1991                .
  3416. .    $                                                          .
  3417. .................................................................
  3418.  
  3419. Problem:      I need to display a message on the screen?
  3420.  
  3421. Solution:     echo command
  3422.  
  3423.  
  3424.  
  3425. The formal form for the echo command is as follows:
  3426.  
  3427. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3428. ”    Command Format: echo message                               ”
  3429. ”                                                               ”
  3430. ”    See the online man pages for details                       ”
  3431. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3432.  
  3433. This command will copy its arguments, followed by a carriage 
  3434. return, to standard output.
  3435.  
  3436.  
  3437. Sample session:
  3438.  
  3439. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3440. ‡    $echo "This is an example"                                 ‡
  3441. ‡    This is an example                                         ‡
  3442. ‡    $                                                          ‡
  3443. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3444. Problem:      I want to send some output to a file and I want to see
  3445.               it displayed on my screen at the same time.
  3446.  
  3447. Solution:     tee command
  3448.  
  3449.  
  3450.  
  3451.  
  3452. The formal form for the tee command is as follows:
  3453.  
  3454. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3455. ”    Command Format: tee [options] file_list                    ”
  3456. ”                                                               ”
  3457. ”    See the online man pages for details                       ”
  3458. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3459.  
  3460.  
  3461. The tee command copies standard input to its standard output and
  3462. to one or more files you specify.
  3463.  
  3464.  
  3465. Sample session:
  3466.  
  3467. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3468. ‡     $date | tee hold.date                                     ‡
  3469. ‡     Wed Dec 19 09:32:22 PST 1984                              ‡
  3470. ‡     $cat hold.date                                            ‡
  3471. ‡     Wed Dec 19 09:32:22 PST 1984                              ‡
  3472. ‡     $                                                         ‡
  3473. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3474. Problem:      What is my terminal pathname?
  3475.  
  3476. Solution:     tty command
  3477.  
  3478.  
  3479.  
  3480.  
  3481. The formal form for the tty command is as follows:
  3482.  
  3483. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3484. ”    Command Format: tty                                        ”
  3485. ”                                                               ”
  3486. ”    See the online man pages for details                       ”
  3487. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3488.  
  3489. The tty command displays the pathname of its standard input file
  3490. if it is a terminal.
  3491.  
  3492.  
  3493. Sample session:                                                  
  3494.                                                                  
  3495. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3496. ‡    $tty                                                       ‡
  3497. ‡    /dev/tty11                                                 ‡
  3498. ‡    $                                                          ‡
  3499. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3500.  
  3501. Problem:      How can I update the modification date of a file
  3502.               without loading it into the editor and really making a
  3503.               change?
  3504.  
  3505. Solution:     touch command
  3506.  
  3507.  
  3508.  
  3509.  
  3510. The formal form for the touch command is as follows:
  3511.  
  3512. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3513. ”    Command Format:  touch [options] file_list                 ”
  3514. ”                                                               ”
  3515. ”    See the online man pages for details                       ”
  3516. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3517.  
  3518. The touch command will read a byte from the file an write it back
  3519. so the update time associated with the file will be updated.  If
  3520. the file doesn't exist it will create it unless you specify the
  3521. option not to create the file.
  3522.  
  3523. Workshop  
  3524.  
  3525. This workshop will reinforce your understanding of the material
  3526. presented in this chapter. Login using the username and the
  3527. password given to you by the instructor.  Each student is to
  3528. complete the entire workshop.
  3529.  
  3530. DESK EXERCISES
  3531.  
  3532.        1. What UNIX command would you use to find out the           
  3533.           differences between two files? 
  3534.  
  3535.  
  3536.  
  3537.  
  3538.  
  3539.        2. How could you find a file in a subdirectory when you      
  3540.           don't know the name?
  3541.  
  3542.  
  3543.  
  3544.  
  3545.  
  3546.        3. What command can link a file to another directory?
  3547.  
  3548.  
  3549.  
  3550.  
  3551.  
  3552.        4. The od command stands for octal dump. Can you display the 
  3553.           contents in hexadecimal?
  3554.  
  3555.  
  3556.  
  3557.  
  3558.  
  3559.        5. What is the command to change group?
  3560.  
  3561.  
  3562.  
  3563.  
  3564.  
  3565.  
  3566.        6. Can I change the ownership of a file that I don't own?
  3567.           What is the command to change the ownership of a file   
  3568.           that I do own?
  3569.  
  3570.  
  3571.  
  3572.  
  3573.  
  3574.                                   Continue on the next page
  3575.  
  3576.        7. What command would you use to kill a child process?
  3577.  
  3578.  
  3579.  
  3580.  
  3581.  
  3582.  
  3583.  
  3584.        8. I want to be nice. What command can I use to lower the    
  3585.           priority of a process?
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.  
  3592.  
  3593.        9. I want to start a process in the background and then      
  3594.           logoff. The child process will run to completion. How?
  3595.  
  3596.  
  3597.  
  3598.  
  3599.  
  3600.  
  3601.        10. What is the at command?
  3602.  
  3603.  
  3604.  
  3605.  
  3606.  
  3607.  
  3608.  
  3609.  
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.                                   Continue on the next page
  3628.  
  3629. COMPUTER EXERCISES
  3630.  
  3631.  
  3632.  
  3633.        11. Use the appropriate command to determine if the file vi  
  3634.            is located in the /bin directory. If not, where is it?
  3635.  
  3636.  
  3637.  
  3638.  
  3639.  
  3640.  
  3641.  
  3642.        12. Create a link to a file in another students directory.
  3643.  
  3644.  
  3645.  
  3646.  
  3647.  
  3648.  
  3649.  
  3650.        13. Run the spell checker against the file called memo.
  3651.  
  3652.  
  3653.  
  3654.  
  3655.  
  3656.  
  3657.        14. How many files are in the teacher subdirectory?
  3658.  
  3659.  
  3660.  
  3661.  
  3662.  
  3663.  
  3664.        15. Change ownership of one of your files to another         
  3665.            student.
  3666.  
  3667.  
  3668.  
  3669.  
  3670.  
  3671.        16. How much disk space is remaining on your directory?
  3672.  
  3673.  
  3674.  
  3675.  
  3676.  
  3677.  
  3678.  
  3679.  
  3680.                                   Continue on the next page
  3681.  
  3682.        17. Make a copy of the file called teacher/prob_17 to        
  3683.            your home directory. Execute it in background. Find    
  3684.            out its PID and then kill it.
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.        18. Use the tee command and echo a message of your choice to 
  3692.            the file called message1 and your monitor screen.
  3693.  
  3694.  
  3695.  
  3696.  
  3697.  
  3698.        19. Logout
  3699. 9.  ADVANCED FEATURES OF FTP
  3700.  
  3701.  
  3702. This chapter will discuss some advanced features of the FTP
  3703. server as implemented on the Multimax.  The introduction of FTP
  3704. in UNIX for Beginning Users gave an elementary introduction to
  3705. some of the features.  If you are not familiar with the basics,
  3706. please refer to that manual.  It is not the purpose to review
  3707. those basics here.
  3708.  
  3709. The FTP (Internet file transfer program) is the user interface to
  3710. the DARPA File Transfer Protocol.  This utility program will
  3711. transfer files to and from a remote computer.  In order for files
  3712. to be transferred from the local computer to a remote computer, a
  3713. connection must be established.  This can be done from the FTP
  3714. command line.  The connection to the remote computer will remain
  3715. active until it is terminated by the user.
  3716.  
  3717. The remote computer with whom the connection is to be made can be
  3718. specified on the FTP command.  In this case, FTP will immediately
  3719. try to establish a connection.  If the remote computer is not
  3720. specified, FTP will enter its command interpreter mode and wait
  3721. for instructions; a prompt will be displayed.
  3722.  
  3723. FTP does have a help feature, and all 58 commands can be listed.
  3724. It will also give a terse description of each command.  In
  3725. addition, there are on-line manual pages which can be accessed by
  3726. using the man command in UMAX.
  3727. 9.1  Initializing FTP on UMAX
  3728.  
  3729.  
  3730. The term, "local computer," will refer to the Multimax.  The
  3731. "remote computer" will refer to the other computer with which you
  3732. are trying to send/receive files.  For purposes of this course,
  3733. we will be referring to the VAX minicomputer as the remote
  3734. computer.  Please be aware that these procedures will work for
  3735. any computer connected to Ethernet and having an FTP server.
  3736.  
  3737. FTP can be invoked on the local computer using the following
  3738. syntax:
  3739.  
  3740. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3741. ”  Command Format:  ftp [-v] [-d] [-i] [-n] [-g] [host]         ”
  3742. ”                                                               ”
  3743. ”         -v = verbose on, forces ftp to show all responses     ”
  3744. ”              from the remote server                           ”
  3745. ”                                                               ”
  3746. ”         -d = enables debugging                                ”
  3747. ”                                                               ”
  3748. ”         -i = turn off interactive prompting during            ”
  3749. ”              multiple file transfers.                         ”
  3750. ”                                                               ”
  3751. ”         -n = disables the "auto-login" feature                ”
  3752. ”                                                               ”
  3753. ”         -g = disable filename globbing                        ”
  3754. ”                                                               ”
  3755. ”         host = the name of the remote computer                ”
  3756. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3757.  
  3758. NOTE:         UMAX (UNIX) is case sensitive.  The commands and
  3759.               options must be entered as shown. 
  3760. 9.2  Multiple File Transfers
  3761.  
  3762.  
  3763. The syntax for the multiple get command is:
  3764.  
  3765. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3766. ”  Command Format:  mget remote-files                           ”
  3767. ”                                                               ”
  3768. ”  remote-files = remote computer wildcard specification        ”
  3769. ”                      or                                       ”
  3770. ”                 file1 file2 ... filen                         ”
  3771. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3772.  
  3773. The remote computer wildcard specification is expanded in a
  3774. process called globbing.  Once the globbing is complete, a get is
  3775. performed on each filename; and it is  transferred to the local
  3776. computer.  The filename is the same on both computers.  You can
  3777. specify the filenames to be transferred separating them with
  3778. spaces.
  3779.  
  3780. Example:
  3781. .................................................................
  3782. . ftp>mget *.dat;*                                              .
  3783. .................................................................
  3784.  
  3785.  
  3786. This command will transfer all versions of the remote-files that
  3787. have the filename extension of .dat.  If the option -i was
  3788. specified on the call to FTP, then the files will be transferred
  3789. automatically.  If the option was not specified, FTP will prompt
  3790. you before transferring each file.
  3791.  
  3792. Sample Session:
  3793.  
  3794. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3795. ‡ ftp>mget *.dat                                                ‡
  3796. ‡ mget change_pass.dat;1?                                       ‡
  3797. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3798.  
  3799.  
  3800. The default is 'yes', pressing (Ret) will cause the file to be
  3801. sent to the local directory.  If you don't want this file
  3802. transferred, enter n(Ret); you will then be prompted for the next
  3803. file, if one exists.
  3804. 9.3  Auto Login Feature
  3805.  
  3806.  
  3807. It is possible to have the login procedure occur automatically. 
  3808. To do this requires a file in your home directory called .netrc.
  3809. The .netrc file contains login and initialization information to
  3810. be used by the auto-login process.  The following variables are
  3811. used and can be separated by spaces, tabs, or new lines.
  3812.  
  3813.  
  3814. machine name  
  3815.  
  3816. This is the name of the remote computer.  The auto-login process
  3817. will search the .netrc file for a machine variable that matches
  3818. the name of the remote computer on the ftp command or as an open
  3819. command argument.  Once a match is found, the next variables are
  3820. also processed until the end of file or another machine variable
  3821. is encountered.
  3822.  
  3823.  
  3824. login name
  3825.  
  3826. This is the username on the remote system.  If this variable is
  3827. present, the auto-login process will login to the remote computer
  3828. with the given username.
  3829.  
  3830.  
  3831. password string
  3832.  
  3833. This is the password to be used when logging into the remote
  3834. system.
  3835.  
  3836. NOTE:         If this variable is present in the .netrc file, ftp
  3837.               will abort the auto-login process if the .netrc file is
  3838.               readable by anyone but the user.
  3839.  
  3840.  
  3841. account string
  3842.  
  3843. This supplies an additional account password.  If present, the
  3844. auto-login process will supply the string as an additional
  3845. password if required by the remote server.
  3846.  
  3847.  
  3848. macdef name
  3849.  
  3850. This defines a macro.  This variable will function like the ftp
  3851. macdef command.  A macro is defined with the specified name, its
  3852. contents begin with the next .netrc line and continue until a
  3853. null line (2 new line characters).  If a macro named init is
  3854. defined, it will be executed as the last step of the auto-login
  3855. process.
  3856. Sample Session:
  3857.  
  3858. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3859. ‡ $cat .netrc                                                   ‡
  3860. ‡ machine erc830                                                ‡
  3861. ‡ login teacher                                                 ‡
  3862. ‡ password secret1                                              ‡
  3863. ‡ machine erc780                                                ‡
  3864. ‡ login rharding                                                ‡
  3865. ‡ password secret2                                              ‡
  3866. ‡ $                                                             ‡
  3867. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3868.  
  3869. To invoke the auto-login feature, type the ftp command and enter
  3870. the name of the remote computer as an argument.
  3871.  
  3872. Sample Session:
  3873.  
  3874. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3875. ‡ $ftp erc830                                                   ‡
  3876. ‡ Connected to erc830.                                          ‡
  3877. ‡ 220 erc830 Wollongong FTP Server (Ver 5.0) at Tue Oct 23      ‡
  3878. ‡ 331 Password required for rharding.                           ‡
  3879. ‡ 230 User logged in, default directory D_1131:[RHARDING]       ‡
  3880. ‡ ftp>                                                          ‡
  3881. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3882.  
  3883. If the .netrc file is readable by anyone other than the user, the
  3884. following error message will appear; and the connection will not
  3885. be made to the remote computer.
  3886.  
  3887. Sample Session:
  3888.  
  3889. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3890. ‡ $ls -l .netrc                                                 ‡
  3891. ‡ $ftp erc830                                                   ‡
  3892. ‡ Connected to erc830.                                          ‡
  3893. ‡ 220 erc830 Wollongong FTP Server (Ver 5.0) at Tue Oct 23      ‡
  3894. ‡ Error - .netrc file not correct mode.                         ‡
  3895. ‡ Remove password or correct code.                              ‡
  3896. ‡ 221 Goodbye.                                                  ‡
  3897. ‡ ftp>                                                          ‡
  3898. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3899.  
  3900. To correct this error, change the mode of the .netrc file so it
  3901. is not readable by other users or remove the password from the
  3902. file.  This is to prevent your password from being read by an
  3903. unauthorized user.
  3904. 9.4  Macros
  3905.  
  3906.  
  3907. Macros are a single instruction that a program replaces by
  3908. several, usually, more complex instructions.  The ftp command to
  3909. create a macro definition is:
  3910.  
  3911. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3912. ”  Command Format:  macdef macro-name                           ”
  3913. ”                                                               ”
  3914. ”  macro-name - the name of the macro                           ”
  3915. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3916.  
  3917. After the macdef command is given, all subsequent lines are
  3918. stored as a macro with the name macro_def.  Consecutive newline
  3919. characters or carriage returns terminate the input mode into the
  3920. macro.  There is a limit of 16 defined macros and a limit of 4096
  3921. characters in all defined macros.
  3922.  
  3923. Sample Session:
  3924.  
  3925. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3926. ‡ ftp>macdef get_files                                          ‡
  3927. ‡ open erc780                                                   ‡
  3928. ‡ get file_1                                                    ‡
  3929. ‡ put result_2                                                  ‡
  3930. ‡ close                                                         ‡
  3931. ‡ ftp>                                                          ‡
  3932. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3933.  
  3934. In this example, the four lines of the macro can be executed
  3935. simply be entering get_files at the ftp prompt.  The macro will
  3936. only exist until the current ftp session is closed.
  3937. 9.5  Filename Translation
  3938.  
  3939.  
  3940. Filename conventions differ from one computer to another, and FTP
  3941. will allow you to translate the name as it is transferred.  One
  3942. way is to specify the name of the file as it is to exist on the
  3943. local computer.  This is done by the argument on the put or get
  3944. command.
  3945.  
  3946. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3947. ”  Command Format:  put local-file [remote-file]                ”
  3948. ”                                                               ”
  3949. ”                   get remote-file [local-file]                ”
  3950. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3951.  
  3952.  
  3953. If you don't specify the remote-file (for the put command) or the
  3954. local-file (for the get command), the name will be the same on
  3955. both the local and remote computer.  This can cause a problem if
  3956. you are not aware of it.  There is an FTP command that will allow
  3957. the name to be translated automatically.
  3958.  
  3959. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3960. ”  Command Format:  nmap [inpattern outpattern]                 ”
  3961. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3962.  
  3963.  
  3964. If no arguments are supplied, it will set or unset the filename
  3965. mapping mechanism.  If arguments are specified, remote filenames
  3966. are mapped during mput (multiple file puts) and put (single file)
  3967. commands that are issued without a specified remote filename.
  3968.  
  3969. If arguments are specified, local filenames are mapped during
  3970. mget (multiple file gets) and get (single file) commands that are
  3971. issued without a specified local filename.
  3972.  
  3973. The mapping follows the pattern set by inpattern and outpattern.
  3974. Variable templating is done by including the sequences "$1",
  3975. "$2",...."$9 "in inpattern.  All other characters are treated
  3976. literally and are used to determine the nmap inpattern variable
  3977. values.
  3978.  
  3979. For example, say the inpattern was $1.$2 and the remote filename
  3980. is mydata.data, $1 would have the value mydata and $2 would have
  3981. the value data.  The outpattern determines the resulting mapped
  3982. filename.  The sequences "$1", "$2",..."$9", are replaced by the
  3983. value resulting from the inpattern template.  "$0" is replaced by
  3984. the original filename.
  3985. 9.6  Aborting Transfers
  3986.  
  3987.  
  3988. Press the terminal interrupt key (usually Ctrl-C) to abort a file
  3989. transfer.  The sending transfer will stop immediately.  Receiving
  3990. transfers will be halted by FTP sending an ABOR command to the
  3991. remote server and discarding any further data that is received.
  3992.  
  3993.  
  3994. If the remote server doesn't support the ABOR protocol command
  3995. the ftp> prompt will not appear until the requested file has been
  3996. sent.
  3997. 9.7  More Remote Computer Commands
  3998.  
  3999. These commands can be useful when working with the directories on
  4000. the remote computer.
  4001.  
  4002. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  4003. ”  Command Format:  cdup                                        ”
  4004. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  4005.  
  4006. This FTP command will change the remote machine current working
  4007. directory to the parent of the current working directory.
  4008.  
  4009.  
  4010. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  4011. ”  Command Format:  delete remote-file                          ”
  4012. ”                                                               ”
  4013. ”  remote-file  name of the file to delete                      ”
  4014. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  4015.  
  4016. This FTP command will delete the specified file.
  4017.  
  4018.  
  4019. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  4020. ”  Command Format:  mdelete [remote-files]                      ”
  4021. ”                                                               ”
  4022. ”  remote-files  names of the files to delete                   ”
  4023. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  4024.                                                                  
  4025. This FTP command acts as a multiple delete.  It will delete all
  4026. the specified files.
  4027.  
  4028.  
  4029. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  4030. ”  Command Format:  mkdir directory-name                        ”
  4031. ”                                                               ”
  4032. ”  directory-name  the name of the directory to be created      ”
  4033. ”                  on the remote computer.                      ”
  4034. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  4035.                                                                  
  4036. This FTP command will create a directory on the remote computer.
  4037.  
  4038.  
  4039. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  4040. ”  Command Format:  rmdir directory-name                        ”
  4041. ”                                                               ”
  4042. ”  directory-name  the name of the directory on the remote      ”
  4043. ”                  computer that will be removed.               ”
  4044. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  4045.  
  4046. This FTP command will remove the specified directory.
  4047.  
  4048. NOTE:         This command will not work with some remote servers.
  4049. Workshop 10
  4050.  
  4051. This workshop will reinforce your understanding of the ideas
  4052. presented in this chapter.  Login using the username and password
  4053. given to you by the instructor.  Each student is to complete the
  4054. entire workshop.
  4055.  
  4056. DESK EXERCISES (10 minutes)
  4057.  
  4058.  
  4059.        1.     What FTP command is used to transfer more than one file
  4060.               at a time? What FTP command will give a prompt to you
  4061.               before each file is retrieved? Suggestion: there are
  4062.               two ways
  4063.  
  4064.  
  4065.  
  4066.  
  4067.  
  4068.        2.     What is the name of the file where the auto-login
  4069.               variables are found?  Extra credit: Why does this file
  4070.               begin with a dot (.)? 
  4071.  
  4072.  
  4073.  
  4074.  
  4075.  
  4076.        3.     How can the file in question the auto-login file be
  4077.               protected from unauthorized reading?
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.        4.     What do the following FTP commands do?
  4084.  
  4085.  
  4086.               cdup
  4087.  
  4088.  
  4089.               delete (tough question)
  4090.  
  4091.  
  4092.               mdelete (ditto)
  4093.  
  4094.  
  4095.               mkdir
  4096.  
  4097.  
  4098.               rmdir
  4099.  
  4100.                                   Continue on the next page
  4101. COMPUTER EXERCISES (30 minutes)
  4102.  
  4103.  
  4104.        5.     Transfer all the files from on the VAX (erc830) to the
  4105.               domax1.  Use only one command and use wildcards.  The
  4106.               username and password for the VAX will be given to you
  4107.               by the instructor. 
  4108.  
  4109.  
  4110.  
  4111.  
  4112.  
  4113.        6.     Transfer the files from the VAX and this time translate
  4114.               the names of the files as they are transferred.
  4115.  
  4116.  
  4117.  
  4118.  
  4119.  
  4120.        7.     Create an auto-login file for the erc830 and
  4121.               then do an auto-login to the VAX.
  4122.  
  4123.  
  4124.  
  4125.  
  4126.  
  4127.        8.     Logout
  4128. APPENDIX A - sh
  4129.  
  4130.  
  4131. NAME
  4132.      sh, rsh - shell, the standard/restricted command programming
  4133.      language
  4134.  
  4135. SYNOPSIS
  4136.      sh [ -acefhiknrstuvx ] [ args ]
  4137.      rsh [ -acefhiknrstuvx ] [ args ]
  4138.  
  4139. DESCRIPTION                                                                   
  4140.      sh is a command programming language that executes commands
  4141.      read from a terminal or a file.  rsh is a restricted version
  4142.      of the standard command interpreter sh; it is used to set up
  4143.      login names and execution environments whose capabilities
  4144.      are more controlled than those of the standard shell.  See
  4145.      Invocation below for the meaning of arguments to the shell.
  4146.                                                                 
  4147.                                                                 
  4148.    Definitions                                                          
  4149.      A blank is a tab or a space.  A name is a sequence of
  4150.      letters, digits, or underscores beginning with a letter or
  4151.      underscore.  A parameter is a name, a digit, or any of the         
  4152.      characters *, @, #, ?, -, $, and !.                                
  4153.                                                                         
  4154.    Commands                                                             
  4155.      A simple-command is a sequence of non-blank words separated        
  4156.      by blanks.  The first word specifies the name of the command       
  4157.      to be executed.  Except as specified below, the remaining          
  4158.      words are passed as arguments to the invoked command.  The         
  4159.      command name is passed as argument 0 (see exec(2)).  The           
  4160.      value of a simple-command is its exit status if it                 
  4161.      terminates normally, or (octal) 200+status if it terminates        
  4162.      abnormally (see signal(2) for a list of status values).            
  4163.                                                                         
  4164.      A pipeline is a sequence of one or more commands separated         
  4165.      by |.  The standard output of each command but the last is         
  4166.      connected by a pipe(2) to the standard input of the next           
  4167.      command.  Each command is run as a separate process; the           
  4168.      shell waits for the last command to terminate.  The exit           
  4169.      status of a pipeline is the exit status of the last command.       
  4170.                                                                         
  4171.      A list is a sequence of one or more pipelines separated by         
  4172.      ;, &, &&, or ||, and optionally terminated by ; or &.  Of          
  4173.      these four symbols, ; and & have equal precedence, which is        
  4174.      lower than that of && and ||.  The symbols && and || also          
  4175.      have equal precedence.  A semicolon (;) causes sequential         
  4176.      execution of the preceding pipeline; an ampersand (&) causes      
  4177.      asynchronous execution of the preceding pipeline (i.e., the       
  4178.      shell does not wait for that pipeline to finish).  The            
  4179.      symbol && (||) causes the list following it to be executed        
  4180.      only if the preceding pipeline returns a zero (non-zero)          
  4181.      exit status.  An arbitrary number of new-lines may appear in      
  4182.      a list, instead of semicolons, to delimit commands.               
  4183.                                                                        
  4184.      A command is either a simple-command or one of the                
  4185.      following.  Unless otherwise stated, the value returned by a
  4186.      command is that of the last simple-command executed in the        
  4187.      command.                                                          
  4188.                                                                        
  4189.      for name [ in word ... ] do list done                             
  4190.           Each time a for command is executed, name is set to the      
  4191.           next word taken from the in word list.  If in word ...       
  4192.           is omitted, then the for command executes the do list        
  4193.           once for each positional parameter that is set (see          
  4194.           Parameter Substitution below).  Execution ends when          
  4195.           there are no more words in the list.                         
  4196.     case word in [ pattern [ | pattern ] ... ) list ;; ] ... esac      
  4197.           A case command executes the list associated with the         
  4198.           first pattern that matches word.  The form of the            
  4199.           patterns is the same as that used for file-name              
  4200.           generation (see File Name Generation) except that a
  4201.           slash, a leading dot, or a dot immediately following a
  4202.           slash need not be matched explicitly.                        
  4203.    if list then list [ elif list then list ] ... [ else list ] fi      
  4204.           The list following if is executed and, if it returns a
  4205.           zero exit status, the list following the first then is
  4206.           executed.  Otherwise, the list following elif is      
  4207.           executed and, if its value is zero, the list following
  4208.           the next then is executed.  Failing that, the else lis
  4209.           is executed.  If no else list or then list is executed
  4210.           then the if command returns a zero exit status.       
  4211.      while list do list done                                    
  4212.           A while command repeatedly executes the while list and
  4213.           if the exit status of the last command in the list is 
  4214.           zero, executes the do list; otherwise the loop        
  4215.           terminates.  If no commands in the do list are        
  4216.           executed, then the while command returns a zero exit  
  4217.           status; until may be used in place of while to negate 
  4218.           the loop termination test.                            
  4219.      (list)                                                     
  4220.           Execute list in a sub-shell.                         
  4221.      { list; }                                                 
  4222.           list is executed in the current (that is, parent)    
  4223.           shell.                                               
  4224.      name () { list; }                                         
  4225.           Define a function which is referenced by name.  The  
  4226.           body of the function is the list of commands between {
  4227.           and }.  Execution of functions is described below (see        
  4228.           Execution).                                                   
  4229.                                                                         
  4230.      The following words are only recognized as the first word of       
  4231.      a command and when not quoted:                                     
  4232.                                                                         
  4233.           if  then  else  elif  fi  case  esac  for  while  until       
  4234.           do  done  {}                                                         
  4235.    Comments                                                             
  4236.      A word beginning with # causes that word and all the               
  4237.      following characters up to a new-line to be ignored.               
  4238.                                                                         
  4239.    Command Substitution                                                 
  4240.      The shell reads commands from the string between two grave         
  4241.      accents (``) and the standard output from these commands may       
  4242.      be used as all or part of a word.  Trailing new-lines from         
  4243.      the standard output are removed.                                   
  4244.                                                                         
  4245.      No interpretation is done on the string before the string is       
  4246.      read, except to remove backslashes (\) used to escape other        
  4247.      characters.  Backslashes may be used to escape a grave             
  4248.      accent (`) or another backslash (\) and are removed before         
  4249.      the command string is read.  Escaping grave accents allows         
  4250.      nested command substitution.  If the command substitution          
  4251.      lies within a pair of double quotes (" ...` ...` ... "), a
  4252.      backslash used to escape a double quote (\") will be                
  4253.      removed; otherwise, it will be left intact.                        
  4254.                                                                         
  4255.      If a backslash is used to escape a new-line character              
  4256.      (\new-line), both the backslash and the new-line are removed       
  4257.      (see the later section on Quoting).  In addition,                  
  4258.      backslashes used to escape dollar signs (\$) are removed.          
  4259.      Since no interpretation is done on the command string before       
  4260.      it is read, inserting a backslash to escape a dollar sign          
  4261.      has no effect.  Backslashes that precede characters other          
  4262.      than \, `, ", new-line, and $ are left intact when the             
  4263.      command string is read.                                            
  4264.                                                                         
  4265.    Parameter Substitution                                               
  4266.      The character $ is used to introduce substitutable                 
  4267.      parameters.  There are two types of parameters, positional         
  4268.      and keyword.  If parameter is a digit, it is a positional          
  4269.      parameter.  Positional parameters may be assigned values by        
  4270.      set.  Keyword parameters (also known as variables) may be          
  4271.      assigned values by writing:                                        
  4272.                                                                         
  4273.           name=value [ name=value ] ...                                 
  4274.                                                                         
  4275.      Pattern-matching is not performed on value.  There cannot be       
  4276.      a function and a variable with the same name.                      
  4277.                                                                         
  4278.      ${parameter}                                                       
  4279.           The value, if any, of the parameter is substituted.           
  4280.           The braces are required only when parameter is followed       
  4281.           by a letter, digit, or underscore that is not to be           
  4282.           interpreted as part of its name.  If parameter is * or        
  4283.           @, all the positional parameters, starting with $1, are       
  4284.           substituted (separated by spaces).  Parameter $0 is set       
  4285.           from argument zero when the shell is invoked.                 
  4286.      ${parameter:-word}                                                 
  4287.           If parameter is set and is non-null, substitute its           
  4288.           value; otherwise substitute word.
  4289.                              
  4290.      ${parameter:=word}                                                 
  4291.           If parameter is not set or is null set it to word; the        
  4292.           value of the parameter is substituted.  Positional            
  4293.           parameters may not be assigned to in this way.                
  4294.      ${parameter:?word}                                                 
  4295.           If parameter is set and is non-null, substitute its           
  4296.           value; otherwise, print word and exit from the shell.         
  4297.           If word is omitted, the message "parameter null or not        
  4298.           set" is printed.                                              
  4299.      ${parameter:+word}                                                 
  4300.           If parameter is set and is non-null, substitute word;         
  4301.           otherwise substitute nothing.                                
  4302.                                                                        
  4303.      In the above, word is not evaluated unless it is to be used       
  4304.      as the substituted string, so that, in the following              
  4305.      example, pwd is executed only if d is not set or is null:        
  4306.                                                                       
  4307.           echo ${d:-`pwd`}                                            
  4308.                                                                       
  4309.      If the colon (:) is omitted from the above expressions, the      
  4310.      shell only checks whether parameter is set or not.               
  4311.                                                                       
  4312.      The following parameters are automatically set by the shell:     
  4313.           #    The number of positional parameters in decimal.        
  4314.           -    Flags supplied to the shell on invocation or by         
  4315.                the set command.                                        
  4316.           ?    The decimal value returned by the last                
  4317.                synchronously executed command.                       
  4318.           $    The process number of this shell.                     
  4319.           !    The process number of the last background command     
  4320.                invoked.                                               
  4321.                                                                       
  4322.      The following parameters are used by the shell:                  
  4323.           HOME  The default argument (home directory) for the cd      
  4324.                 command.                                              
  4325.           PATH  The search path for commands (see Execution           
  4326.                    below).  The user may not change PATH if                    
  4327.         executing under rsh.                                     
  4328.           CDPATH                                                  
  4329.                 The search path for the cd command.               
  4330.           MAIL  If this parameter is set to the name of a mail    
  4331.                 file and the MAILPATH parameter is not set, the   
  4332.                 shell informs the user of the arrival of mail in  
  4333.                 the specified file.                               
  4334.           MAILCHECK                                               
  4335.                 This parameter specifies how often (in seconds)       
  4336.                 the shell will check for the arrival of mail in       
  4337.                 the files specified by the MAILPATH or MAIL           
  4338.                 parameters.  The default value is 600 seconds (10     
  4339.                 minutes).  If set to 0, the shell will check          
  4340.                 before each prompt.                                   
  4341.  
  4342.  
  4343.  
  4344.  
  4345.           MAILPATH                                                   
  4346.                 A colon (:) separated list of file names.  If         
  4347.                 this parameter is set, the shell informs the user    
  4348.                 of the arrival of mail in any of the specified       
  4349.                 files. Each file name can be followed by % and a
  4350.                 message that will be printed when the                
  4351.                 modification time changes.  The default message      
  4352.                 is you have mail.                                      
  4353.           PS1   Primary prompt string, by default "$ ".                
  4354.           PS2   Secondary prompt string, by default "> ".              
  4355.           IFS   Internal field separators, normally space, tab,        
  4356.                 and new-line.                                          
  4357.           SHACCT                                               
  4358.                 If this parameter is set to the name of a file 
  4359.                 writable by the user, the shell will write an          
  4360.                 accounting record in the file for each shell           
  4361.                 procedure executed.  Accounting routines such as       
  4362.                 acctcom(1) and acctcms(1M) can be used to analyze      
  4363.                 the data collected.                                   
  4364.           SHELL When the shell is invoked, it scans the                
  4365.                 environment (see Environment below) for this           
  4366.                 name.  If it is found and 'rsh' is the file name       
  4367.                 part of its value, the shell becomes a restricted      
  4368.                 shell.                                                 
  4369.                                                                        
  4370.      The shell gives default values to PATH, PS1, PS2, MAILCHECK       
  4371.      and IFS.  HOME and MAIL are set by login(1).                      
  4372.                                                                        
  4373.    Blank Interpretation                                                
  4374.      After parameter and command substitution, the results of         
  4375.      substitution are scanned for internal field separator            
  4376.      characters (those found in IFS) and split into distinct          
  4377.      arguments where such characters are found.  Explicit null        
  4378.      arguments ("" or '') are retained.  Implicit null arguments      
  4379.      (those resulting from parameters that have no values) are        
  4380.      removed.                                                        
  4381.                                                                      
  4382.    Input/Output                                                       
  4383.      A command's input and output may be redirected using a
  4384.      special notation interpreted by the shell.  The following     
  4385.      may appear anywhere in a simple-command or may precede or     
  4386.      follow a command and are not passed on to the invoked            
  4387.      command; substitution occurs before word or digit is used:       
  4388.                                                                       
  4389.      <word         Use file word as standard input (file              
  4390.                    descriptor 0).                                     
  4391.      >word         Use file word as standard output (file             
  4392.                    descriptor 1).  If the file does not exist it      
  4393.                    is created; otherwise, it is truncated to zero     
  4394.                    length.                                            
  4395.      >>word        Use file word as standard output.  If the file     
  4396.                    exists output is appended to it (by first          
  4397.                    seeking to the end-of-file); otherwise, the        
  4398.                    file is created.                                   
  4399.  
  4400.      <<[-]word     After parameter and command substitution are       
  4401.                    done on word, the shell input is read up to        
  4402.                    the first line that literally matches the          
  4403.                    resulting word, or to an end-of-file.  If,         
  4404.                    however, - is appended to <<:                      
  4405.                    1)  leading tabs are stripped from word before     
  4406.                        the shell input is read (but after             
  4407.                        parameter and command substitution is done     
  4408.                        on word),                                      
  4409.                    2)  leading tabs are stripped from the shell       
  4410.                        input as it is read and before each line       
  4411.                        is compared with word, and                     
  4412.                    3)  shell input is read up to the first line       
  4413.                        that literally matches the resulting word,     
  4414.                        or to an end-of-file.                          
  4415.                    If any character of word is quoted (see            
  4416.                    Quoting, later), no additional processing is       
  4417.                    done to the shell input.  If no characters of      
  4418.                    word are quoted:                                   
  4419.                    1)  parameter and command substitution occurs,     
  4420.                    2)  (escaped) \newline is ignored, and             
  4421.                    3)  \ must be used to quote the characters \,      
  4422.                        $, and `.                                       
  4423.                    The resulting document becomes the standard         
  4424.                    input.                                              
  4425.      <&digit       Use the file associated with file descriptor        
  4426.                    digit as standard input.  Similarly for the         
  4427.                    standard output using >&digit.                     
  4428.      <&-           The standard input is closed.  Similarly for       
  4429.                    the standard output using >&--.                    
  4430.                                                                       
  4431.      If any of the above is preceded by a digit, the file             
  4432.      descriptor which will be associated with the file is that        
  4433.      specified by the digit (instead of the default 0 or 1).  For     
  4434.      example:                                                         
  4435.                                                                       
  4436.           ... 2>&1                                                    
  4437.                                                                       
  4438.      associates file descriptor 2 with the file currently             
  4439.      associated with file descriptor 1.                               
  4440.                                                                       
  4441.      The order in which redirections are specified is                 
  4442.      significant.  The shell evaluates redirections left-to-          
  4443.      right.  For example:                                             
  4444.                                                                      
  4445.           ... 1>xxx  2>&1                                            
  4446.                                                                       
  4447.      first associates file descriptor 1 with file xxx.  It            
  4448.      associates file descriptor 2 with the file associated with       
  4449.      file descriptor 1 (i.e. xxx).  It directs both standard          
  4450.      output and standard error output (stdout, stderr) to xxx.        
  4451.      If the order of redirections were reversed, file descriptor      
  4452.      2 would be associated with the terminal (assuming file           
  4453.      descriptor 1 had been) and file descriptor 1 would be            
  4454.      associated with file xxx.                                                 
  4455.      Using the terminology introduced on the first page, under       
  4456.      Commands, if a command is composed of several simple            
  4457.      commands, redirection will be evaluated for the entire           
  4458.      command before it is evaluated for each simple command.          
  4459.      That is, the shell evaluates redirection for the entire          
  4460.      list, then each pipeline within the list, the each command       
  4461.      within each pipeline, then each list within each command.        
  4462.                                                                       
  4463.      If a command is followed by & the default standard input for    
  4464.      the command is the empty file /dev/null.  Otherwise, the        
  4465.      environment for the execution of a command contains the file    
  4466.      descriptors of the invoking shell as modified by                
  4467.      input/output specifications.                                    
  4468.                                                                    
  4469.      Redirection of output is not allowed in the restricted        
  4470.      shell.                                                           
  4471.                                                                       
  4472.    File Name Generation                                                
  4473.      Before a command is executed, each command word is scanned        
  4474.      for the characters *, ?, and [.  If one of these characters      
  4475.      appears, the word is regarded as a pattern.  The word is         
  4476.      replaced with alphabetically sorted file names that match         
  4477.      the pattern.  If no file name is found that matches the          
  4478.      pattern, the word is left unchanged.  The character . at the     
  4479.      start of a file name or immediately following a /, as well       
  4480.      as the character / itself, must be matched explicitly.           
  4481.                                                                     
  4482.           *       Matches any string, including the null string.    
  4483.           ?       Matches any single character.                     
  4484.           [...]   Matches any one of the enclosed characters.  A
  4485.                   pair of characters separated by - matches any     
  4486.                   character lexically between the pair,             
  4487.                   inclusive.  If the first character following      
  4488.                   the opening "[" is a "!" any character not        
  4489.                   enclosed is matched.                              
  4490.                                                                     
  4491.    Quoting                                                          
  4492.      The following characters have a special meaning to the shell  
  4493.      and cause termination of a word unless quoted:                
  4494.                                                                    
  4495.           ;  &  (  )  |  ^  <  >  new-line  space  tab
  4496.                                                                    
  4497.      A character may be quoted (i.e., made to stand for itself)    
  4498.      by preceding it with a backslash (\) or inserting it between 
  4499.      a pair of quote marks ('' or "").  During processing, the    
  4500.      shell may quote certain characters to prevent them from      
  4501.      taking on a special meaning. Backslashes used to quote a
  4502.      single character are removed from the word before the       
  4503.      command is executed.  The pair \newline is removed from a
  4504.      word before command and parameter substitution.             
  4505.                                                                  
  4506.  
  4507.  
  4508.  
  4509.  
  4510.      All characters enclosed between a pair of single quote marks
  4511.      (''), except a single quote, are quoted by the shell.      
  4512.      Backslash has no special meaning inside a pair of single   
  4513.      quotes.  A single quote may be quoted inside a pair of    
  4514.      double quote marks (for example, "'").                    
  4515.                                                                
  4516.      Inside a pair of double quote marks (""), parameter and   
  4517.      command substitution occurs and the shell quotes the results  
  4518.      to avoid blank interpretation and file name generation. If    
  4519.      $* is within a pair of double quotes, the positional          
  4520.      parameters are substituted and quoted, separated by quoted    
  4521.      spaces ("$1 $2 ..."); however, if $@ is within a pair of        
  4522.      double quotes, the positional parameters are substituted and    
  4523.      quoted, separated by unquoted spaces ("$1" "$2" ...).  \        
  4524.      quotes the characters \, `, ", and $.  The pair \newline is     
  4525.      removed before parameter and command substitution.  If a
  4526.      backslash precedes characters other than \, `, ", $, and        
  4527.      new-line, the backslash itself is quoted by the shell.          
  4528.                                                                      
  4529.    Prompting                                                         
  4530.      When used interactively, the shell prompts with the value of    
  4531.      PS1 before reading a command.  If at any time a new-line is      
  4532.      typed and further input is needed to complete a command, the     
  4533.      secondary prompt (i.e., the value of PS2) is issued.             
  4534.                                                                        
  4535.    Environment                                                         
  4536.      The environment (see environ(5)) is a list of name-value          
  4537.      pairs that is passed to an executed program in the same way       
  4538.      as a normal argument list.  The shell interacts with the         
  4539.      environment in several ways.  On invocation, the shell scans     
  4540.      the environment and creates a parameter for each name found,     
  4541.      giving it the corresponding value.  If the user modifies the     
  4542.      value of any of these parameters or creates new parameters,      
  4543.      none of these affects the environment unless the export          
  4544.      command is used to bind the shell's parameter to the             
  4545.      environment (see also set -a).  A parameter may be removed       
  4546.      from the environment with the unset command.  The                
  4547.      environment seen by any executed command is thus composed of     
  4548.      any unmodified name-value pairs originally inherited by the      
  4549.      shell, minus any pairs removed by unset, plus any                
  4550.      modifications or additions, all of which must be noted in         
  4551.      export commands.                                                  
  4552.                                                                        
  4553.      The environment for any simple-command may be augmented by        
  4554.      prefixing it with one or more assignments to parameters.          
  4555.      Thus:                                                             
  4556.                                                                        
  4557.           TERM=450 cmd                                                 
  4558.      and                                                               
  4559.           (export TERM; TERM=450; cmd)                                 
  4560.                                                                        
  4561.      are equivalent (as far as the execution of cmd is                 
  4562.      concerned).                                                       
  4563.  
  4564.                                                                        
  4565.      If the -k flag is set, all keyword arguments are placed in        
  4566.      the environment, even if they occur after the command name.       
  4567.      The following first prints a=b c and c:                          
  4568.                                                                       
  4569.           echo a=b c                                                 
  4570.           set -k                                                     
  4571.           echo a=b c                                                   
  4572.                                                                        
  4573.    Signals                                                             
  4574.      The INTERRUPT and QUIT signals for an invoked command are         
  4575.      ignored if the command is followed by &; otherwise signals       
  4576.      have the values inherited by the shell from its parent, with     
  4577.      the exception of signal 11 (SIGSEGV) (but see also the trap      
  4578.      command below).  See nohup(1) for more signal handling.          
  4579.                                                                        
  4580.    Execution                                                           
  4581.      Each time a command is executed, the above substitutions are      
  4582.      carried out.  If the command name matches one of the Special      
  4583.      Commands listed below, it is executed in the shell process.       
  4584.      If the command name does not match a Special Command, but         
  4585.      matches the name of a defined function, the function is          
  4586.      executed in the shell process (note how this differs from        
  4587.      the execution of shell procedures).  The positional               
  4588.      parameters $1, $2, ....  are set to the arguments of the          
  4589.      function.  If the command name matches neither a Special          
  4590.      Command nor the name of a defined function, a new process is      
  4591.      created and an attempt is made to execute the command via
  4592.      exec(2).                                                          
  4593.                                                                        
  4594.      The shell parameter PATH defines the search path for the          
  4595.      directory containing the command.  Alternative directory         
  4596.      names are separated by a colon (:).  The default path is         
  4597.      :/bin:/usr/bin (specifying the current directory, /bin, and       
  4598.      /usr/bin, in that order).  Note that the current directory        
  4599.      is specified by a null path name, which can appear                
  4600.      immediately after the equal sign or between the colon             
  4601.      delimiters anywhere else in the path list.  If the command        
  4602.      name contains a / the search path is not used; such commands      
  4603.      will not be executed by the restricted shell.  Otherwise,         
  4604.      each directory in the path is searched for an executable          
  4605.      file.  If the file has execute permission but is not an          
  4606.      a.out file, it is assumed to be a file containing shell          
  4607.      commands.  A sub-shell is spawned to read it.  A
  4608.      parenthesized command is also executed in a sub-shell.           
  4609.                                                                       
  4610.      The location in the search path where a command was found is     
  4611.      remembered by the shell (to help avoid unnecessary execs         
  4612.      later).  If the command was found in a relative directory,       
  4613.      its location must be re-determined whenever the current         
  4614.      directory changes.  The shell forgets all remembered            
  4615.      locations whenever the PATH variable is changed or the hash      
  4616.      -r command is executed (see below).                              
  4617.  
  4618.  
  4619.                                                                       
  4620.    Special Commands                                                   
  4621.      Input/output redirection is now permitted for these              
  4622.      commands.  File descriptor 1 is the default output location.     
  4623.                                                                       
  4624.      :                                                                
  4625.           No effect; the command does nothing.  A zero exit code      
  4626.           is returned.                                                
  4627.      . file                                                           
  4628.           Read and execute commands from file and return.  The        
  4629.           search path specified by PATH is used to find the           
  4630.           directory containing file.                                    
  4631.      break [ n ]                                                       
  4632.           Exit from the enclosing for or while loop, if any.  If      
  4633.           n is specified break n levels.                              
  4634.      continue [ n ]                                                  
  4635.           Resume the next iteration of the enclosing for or while    
  4636.           loop.  If n is specified resume at the nth enclosing       
  4637.           loop.                                                      
  4638.      cd [ arg ]                                                      
  4639.           Change the current directory to arg.  The shell             
  4640.           parameter HOME is the default arg.  The shell parameter     
  4641.           CDPATH defines the search path for the directory             
  4642.           containing arg.  Alternative directory names are             
  4643.           separated by a colon (:).  The default path is <null>        
  4644.           (specifying the current directory).  Note that the           
  4645.           current directory is specified by a null path name,          
  4646.           which can appear immediately after the equal sign or         
  4647.           between the colon delimiters anywhere else in the path     
  4648.           list.  If arg begins with a / the search path is not       
  4649.           used.  Otherwise, each directory in the path is             
  4650.           searched for arg.  The cd command may not be executed       
  4651.           by rsh.                                                     
  4652.      echo [ arg ... ]                                                 
  4653.           Echo arguments. See echo(1) for usage and description.      
  4654.      eval [ arg ... ]                                                 
  4655.           The arguments are read as input to the shell and the        
  4656.           resulting command(s) executed.                            
  4657.      exec [ arg ... ]                                                 
  4658.           The command specified by the arguments is executed in       
  4659.           place of this shell without creating a new process.         
  4660.           Input/output arguments may appear and, if no other          
  4661.           arguments are given, cause the shell input/output to be     
  4662.           modified.                                                   
  4663.      exit [ n ]                                                       
  4664.           Causes a shell to exit with the exit status specified       
  4665.           by n.  If n is omitted the exit status is that of the       
  4666.           last command executed (an end-of-file will also cause       
  4667.           the shell to exit.)                                          
  4668.  
  4669.  
  4670.  
  4671.  
  4672.  
  4673.  
  4674.  
  4675.      export [ name ... ]                                               
  4676.           The given names are marked for automatic export to the       
  4677.           environment of subsequently-executed commands.  If no        
  4678.           arguments are given, a list of all names that are            
  4679.           exported in this shell is printed.  (Variable names         
  4680.           exported from a parent shell are listed only if they        
  4681.           have been exported again during the current shell's         
  4682.           execution.) Function names may not be exported.             
  4683.      getopts                                                          
  4684.           Use in shell script to support command syntax standards     
  4685.           (see intro(1)); it parses positional parameters and         
  4686.           checks for legal options.  See getopts(1) for usage and     
  4687.           description.                                                
  4688.      hash [ -r ] [ name ... ]                                         
  4689.           For each name, the location in the search path of the       
  4690.           command specified by name is determined and remembered      
  4691.           by the shell.  The -r option causes the shell to forget     
  4692.           all remembered locations.  If no arguments are given,       
  4693.           information about remembered commands is presented.         
  4694.           hits is the number of times a command has been invoked      
  4695.           by the shell process.  cost is a measure of the work        
  4696.           required to locate a command in the search path.  If a
  4697.           command is found in a "relative" directory in the           
  4698.           search path, after changing to that directory, the          
  4699.           stored location of that command is recalculated.            
  4700.           Commands for which this will be done are indicated by       
  4701.           an asterisk (*) adjacent to the hits information.  cost     
  4702.           will be incremented when the recalculation is done.         
  4703.      newgrp [ arg ... ]                                               
  4704.           Equivalent to exec newgrp arg ....  See newgrp(1M) for      
  4705.           usage and description.                                      
  4706.      pwd                                                              
  4707.           Print the current working directory.  See pwd(1) for         
  4708.           usage and description.                                      
  4709.      read [ name ... ]                                                
  4710.           One line is read from the standard input and, using the     
  4711.           internal field separator, IFS (normally space or tab),     
  4712.           to delimit word boundaries, the first word is assigned     
  4713.           to the first name, the second word to the second name,     
  4714.           etc., with leftover words assigned to the last name.        
  4715.           Lines can be continued using \new-line.  Characters        
  4716.           other than new-line can be quoted by preceding them        
  4717.           with a backslash.  These backslashes are removed before     
  4718.           words are assigned to names, and no interpretation is       
  4719.           done on the character that follows the backslash.  The      
  4720.           return code is 0 unless an end-of-file is encountered.      
  4721.      readonly [ name ... ]                                            
  4722.           The given names are marked readonly and the values of       
  4723.           these names may not be changed by subsequent                
  4724.           assignment.  If no arguments are given, a list of all       
  4725.           readonly names is printed.                                  
  4726.      return [ n ]                                                      
  4727.           Causes a function to exit with the return value              
  4728.           specified by n.  If n is omitted, the return status is       
  4729.           that of the last command executed.                           
  4730.      set [ --aefhkntuvx [ arg ... ] ]                                 
  4731.           -a
  4732.  Mark variables which are modified or created for        
  4733.                export.                                   
  4734.           -e   Exit immediately if a command exits with a non-    
  4735.                zero exit status.                                  
  4736.           -f   Disable file name generation.                      
  4737.           -h   Locate and remember function commands as functions 
  4738.                are defined (function commands are normally           
  4739.                located when the function is executed).               
  4740.           -k   All keyword arguments are placed in the               
  4741.                environment for a command, not just those that        
  4742.                precede the command name.                              
  4743.           -n   Read commands but do not execute them.                 
  4744.           -t   Exit after reading and executing one command.          
  4745.           -u   Treat unset variables as an error when                 
  4746.                substituting.                                          
  4747.           -v   Print shell input lines as they are read.              
  4748.           -x   Print commands and their arguments as they are        
  4749.                executed.                                              
  4750.           --   Do not change any of the flags; useful in setting      
  4751.                $1 to -.                                              
  4752.           Using + rather than - causes these flags to be turned      
  4753.           off.  These flags can also be used upon invocation of      
  4754.           the shell.  The current set of flags may be found in       
  4755.           $-.  The remaining arguments are positional parameters       
  4756.           and are assigned, in order, to $1, $2, ....  If no           
  4757.           arguments are given the values of all names are           
  4758.           printed.                                                  
  4759.      shift [ n ]                                                    
  4760.           The positional parameters from $n+1 ... are renamed $1       
  4761.           ....  If n is not given, it is assumed to be 1.            
  4762.      test                                                            
  4763.           Evaluate conditional expressions. See test(1) for usage     
  4764.           and description.                                            
  4765.      times                                                            
  4766.           Print the accumulated user and system times for             
  4767.           processes run from the shell.                               
  4768.      trap [ arg ] [ n ] ...                                           
  4769.           The command arg is to be read and executed when the         
  4770.           shell receives signal(s) n.  (Note that arg is scanned      
  4771.           once when the trap is set and once when the trap is         
  4772.           taken.) Trap commands are executed in order of signal       
  4773.           number.  Any attempt to set a trap on a signal that was     
  4774.           ignored on entry to the current shell is ineffective.       
  4775.           An attempt to trap on signal 11 (memory fault) produces     
  4776.           an error.  If arg is absent all trap(s) n are reset to      
  4777.           their original values.  If arg is the null string this      
  4778.           signal is ignored by the shell and by the commands it       
  4779.           invokes.  If n is 0 the command arg is executed on exit     
  4780.           from the shell.  The trap command with no arguments         
  4781.           prints a list of commands associated with each signal       
  4782.           number.                                                     
  4783.  
  4784.  
  4785.      type [ name ... ]                                                
  4786.           For each name, indicate how it would be interpreted if      
  4787.           used as a command name.                                     
  4788.      ulimit [ n ]                                                     
  4789.           Impose a size limit of n blocks on files written by the     
  4790.           shell and its child processes (files of any size may be     
  4791.           read).  If n is omitted, the current limit is printed.      
  4792.           Each user may lower the ulimit, but only a super-user       
  4793.           (see su(1M)) can raise a ulimit.                            
  4794.      umask [ nnn ]                                                    
  4795.           The user file-creation mask is set to nnn (see              
  4796.           umask(1)).  If nnn is omitted, the current value of the     
  4797.           mask is printed.                                            
  4798.      unset [ name ... ]                                               
  4799.           For each name, remove the corresponding variable or         
  4800.           function.  The variables PATH, PS1, PS2, MAILCHECK and      
  4801.           IFS cannot be unset.                                        
  4802.      wait [ n ]                                                       
  4803.           Wait for a background process whose process ID is n and     
  4804.           report its termination status.  If n is omitted, all        
  4805.           the shell's currently active background processes are       
  4806.           waited for and the return code will be zero.                
  4807.                                                                      
  4808.    Invocation                                                        
  4809.      If the shell is invoked through exec(2) and the first           
  4810.      character of argument zero is -, commands are initially read    
  4811.      from /etc/profile and from $HOME/.profile, if such files        
  4812.      exist.  Thereafter, commands are read as described below,       
  4813.      which is also the case when the shell is invoked as /bin/sh.    
  4814.      The flags below are interpreted by the shell on invocation      
  4815.      only.  Note that unless the -c or -s flag is specified, the     
  4816.      first argument is assumed to be the name of a file              
  4817.      containing commands, and the remaining arguments are passed     
  4818.      as positional parameters to that command file:                  
  4819.                                                                       
  4820.      -c string If the -c flag is present commands are read from       
  4821.                string.                                                
  4822.      -s        If the -s flag is present or if no arguments           
  4823.                remain commands are read from the standard input.      
  4824.                Any remaining arguments specify the positional         
  4825.                parameters.  Shell output (except for Special          
  4826.                Commands) is written to file descriptor 2.             
  4827.      -i        If the -i flag is present or if the shell input        
  4828.                and output are attached to a terminal, this shell      
  4829.                is interactive.  In this case TERMINATE is ignored     
  4830.                (so that kill 0 does not kill an interactive           
  4831.                shell) and INTERRUPT is caught and ignored (so         
  4832.                that wait is interruptible).  In all cases, QUIT       
  4833.                is ignored by the shell.                               
  4834.      -r        If the -r flag is present the shell is a
  4835.                restricted shell.                       
  4836.                                                                      
  4837.  
  4838.      The remaining flags and arguments are described under the       
  4839.      set command above.                                                        
  4840.    rsh Only                                                          
  4841.      rsh is used to set up login names and execution environments    
  4842.      whose capabilities are more controlled than those of the        
  4843.      standard shell.  The actions of rsh are identical to those       
  4844.      of sh, except that the following are disallowed:                 
  4845.                                                                       
  4846.           changing directory (see cd(1)),                             
  4847.           setting the value of $PATH,                                 
  4848.           specifying path or command names containing /,              
  4849.           redirecting output (> and >>).                              
  4850.                                                                       
  4851.      The restrictions above are enforced after .profile is            
  4852.      interpreted.                                                     
  4853.                                                                       
  4854.      A restricted shell can be invoked in one of the following        
  4855.      ways: (1) rsh is the file name part of the last entry in the     
  4856.      /etc/passwd file (see passwd(4)); (2) the environment            
  4857.      variable SHELL exists and rsh is the file name part of its       
  4858.      value; (3) the shell is invoked and rsh is the file name         
  4859.      part of argument 0; (4) the shell is invoked with the -r         
  4860.      option.                                                          
  4861.                                                                       
  4862.      When a command to be executed is found to be a shell             
  4863.      procedure, rsh invokes sh to execute it.  Thus, it is            
  4864.      possible to provide to the end-user shell procedures that        
  4865.      have access to the full power of the standard shell, while       
  4866.      imposing a limited menu of commands; this scheme assumes         
  4867.      that the end-user does not have write and execute                
  4868.      permissions in the same directory.                               
  4869.                                                                       
  4870.      The net effect of these rules is that the writer of the          
  4871.      .profile has complete control over user actions, by              
  4872.      performing guaranteed setup actions and leaving the user in      
  4873.      an appropriate directory (probably not the login directory).     
  4874.                                                                       
  4875.      The system administrator often sets up a directory of            
  4876.      commands (i.e., /usr/rbin) that can be safely invoked by         
  4877.      rsh.  Some systems also provide a restricted editor red.         
  4878.                                                                       
  4879. EXIT STATUS                                                           
  4880.      Errors detected by the shell, such as syntax errors, cause       
  4881.      the shell to return a non-zero exit status.  If the shell is     
  4882.      being used non-interactively execution of the shell file is      
  4883.      abandoned.  Otherwise, the shell returns the exit status of      
  4884.      the last command executed (see also the exit command above).     
  4885.                                                                       
  4886. FILES                                                                 
  4887.      /etc/profile                                                     
  4888.      $HOME/profile                                                    
  4889.      /tmp/sh*                                                         
  4890.      /dev/null                                                        
  4891.                                                                       
  4892.  
  4893.  
  4894.  
  4895. SEE ALSO                                                              
  4896.      acctcom(1), cd(1), echo(1), env(1), ksh(1), login(1),            
  4897.      pwd(1), test(1), umask(1).                                       
  4898.      acctcms(1M), newgrp(1M), su(1M) in the UMAX V                    
  4899.      Administrator's Reference Manual.                                
  4900.      dup(2), exec(2), fork(2), pipe(2), signal(2), ulimit(2),         
  4901.      wait(2), a.out(4), passwd(4), profile(4), environ(5) in the      
  4902.      UMAX V Programmer's Reference Manual.                            
  4903.                                                                       
  4904. CAVEATS                                                               
  4905.      Words used for filenames in input/output redirection are not     
  4906.      interpreted for filename generation (see File Name               
  4907.      Generation, above).  For example, cat file1 > a* will create     
  4908.      a file named a*.                                                 
  4909.                                                                       
  4910.      Because commands in pipelines are run as separate processes,     
  4911.      variables set in a pipeline have no effect on the parent         
  4912.      shell.                                                           
  4913.                                                                       
  4914.      If the error message cannot fork, too many processes is          
  4915.      displayed, try using the wait(1) command to clean up the         
  4916.      background processes.  If this does not help, the system         
  4917.      process table is probably full or there are too many active      
  4918.      foreground processes.  (There is a limit to the number of        
  4919.      process IDs associated with a login and to the number of         
  4920.      which the system can keep track.)                                
  4921. BUGS                                                                  
  4922.      If a command is executed, and a command with the same name       
  4923.      is installed in a directory in the search path before the        
  4924.      directory where the original command was found, the shell        
  4925.      will continue to exec the original command.  Use the hash        
  4926.      command to correct this situation.                               
  4927.                                                                       
  4928.      If the current directory or one above it is moved, pwd may       
  4929.      not give the correct response.  Use the cd command with a
  4930.      full path name to correct this situation.                        
  4931.                                                                       
  4932.      Not all the processes of a 3- or more-stage pipeline are         
  4933.      children of the shell, and thus cannot be waited for.            
  4934.                                                                       
  4935.      For wait n, if n is not an active process id, all the            
  4936.      shell's currently active background processes are waited for     
  4937.      and the return code will be zero.                           
  4938. APPENDIX B - ftp
  4939.  
  4940.  
  4941. $man ftp                                                               
  4942.                                                                        
  4943. NAME                                                                   
  4944.      ftp - Internet file transfer program                              
  4945.                                                                        
  4946. SYNOPSIS                                                               
  4947.      ftp [ -v ] [ -d ] [ -i ] [ -n ] [ -g ] [ host ]                   
  4948.                                                                        
  4949. DESCRIPTION                                                            
  4950.      ftp is the user interface to the DARPA File Transfer              
  4951.      Protocol. The program transfers files to and from a remote        
  4952.      network site.                                                     
  4953.                                                                        
  4954.      The client host with which ftp is to communicate can be           
  4955.      specified on the command line. In this case, ftp immediately      
  4956.      attempts to establish a connection to an FTP server on that       
  4957.      host; otherwise, ftp enters its command interpreter and           
  4958.      waits for instruction, displaying the prompt ftp>.                
  4959.                                                                        
  4960.      ftp recognizes the following commands:                            
  4961.                                                                        
  4962.      ! [ command [ args ] ]                                            
  4963.                Invoke an interactive shell on the local machine.       
  4964.                If there are arguments, the first is taken to be a
  4965.                command to execute directly, with the rest of the       
  4966.                arguments as its arguments.                             
  4967.                                                                        
  4968.      $ macro-name [ args ]                                             
  4969.                Execute the macro-name that was defined with     
  4970.                the macdef command.  Arguments are passed to the 
  4971.                macro unglobbed.                                 
  4972.                                                                 
  4973.      account [ passwd ]                                         
  4974.                Supply a supplemental password required by a
  4975.                remote system for access to resources once a login      
  4976.                has been successfully completed.  If no argument        
  4977.                is included, the user will be prompted for an           
  4978.                account password in a non-echoing input mode.           
  4979.                                                                        
  4980.      append local-file [ remote-file ]                                 
  4981.                Append a local file to a file on the remote             
  4982.                machine. If remote-file is left unspecified, the        
  4983.                local file name is used to name the remote file         
  4984.                after being altered by any ntrans or nmap setting.      
  4985.                File transfer uses the current settings for type,       
  4986.                format, mode, and structure.                            
  4987.                                                                        
  4988.      ascii     Set the file transfer type to network ASCII. This       
  4989.                is the default type.                                            
  4990.      bell      Sound a bell after each file transfer command is        
  4991.                completed.                                              
  4992.                                                                        
  4993.      binary    Set the file transfer type to support binary image      
  4994.                transfer.                                               
  4995.                                                                        
  4996.      bye       Terminate the FTP session with the remote server        
  4997.                and exit ftp.                                           
  4998.                                                                        
  4999.      case      Toggle remote computer file name case mapping           
  5000.                during mget commands.  When case is on (default is      
  5001.                off), remote computer file names with all letters       
  5002.                in upper case are written in the local directory        
  5003.                with the letters mapped to lower case.                  
  5004.                                                                        
  5005.      cd remote-directory                                               
  5006.                Change the working directory on the remote machine      
  5007.                to remote-directory.                                    
  5008.                                                                        
  5009.      cdup      Change the remote machine working directory to the     
  5010.                parent of the current remote machine working           
  5011.                directory.                                             
  5012.                                                                       
  5013.      close     Terminate the FTP session with the remote server,      
  5014.                and return to the command interpreter.  Any            
  5015.                defined macros are erased.                             
  5016.                                                                       
  5017.      cr        Toggle carriage return stripping during ASCII type     
  5018.                file retrieval.  Records are denoted by a carriage     
  5019.                return/linefeed sequence during ASCII type file        
  5020.                transfer.  When cr is on (the default), carriage       
  5021.                returns are stripped from this sequence to conform     
  5022.                with the UNIX single linefeed record delimiter.        
  5023.                Records on non-UNIX remote systems may contain         
  5024.                single linefeeds; when an ASCII type transfer is       
  5025.                made, these linefeeds may be distinguished from a
  5026.                record delimiter only when cr is off.                  
  5027.                                                                       
  5028.      delete remote-file                                               
  5029.                Delete the file remote-file on the remote machine.     
  5030.                                                                       
  5031.      debug [ debug-value ]                                            
  5032.                Toggle debugging mode. If an optional debug-value      
  5033.                is specified, it is used to set the debugging          
  5034.                level. When debugging is on, ftp prints each           
  5035.                command sent to the remote machine, preceded by        
  5036.                the string --> .                                       
  5037.                                                                       
  5038.  
  5039.  
  5040.  
  5041.  
  5042.      dir [ remote-directory ] [ local-file ]                          
  5043.                Print the contents of directory, remote-directory,     
  5044.                and, optionally, place the output in local-file.       
  5045.                If no directory is specified, the current working      
  5046.                directory on the remote machine is used. If no         
  5047.                local file is specified, or local-file is -,           
  5048.                output comes to the terminal.                          
  5049.                                                                       
  5050.      disconnect                                                       
  5051.                A synonym for close.                                   
  5052.                                                                       
  5053.      form format                                                      
  5054.                Set the file transfer form to format.  The default      
  5055.                format is file.                                         
  5056.                                                                        
  5057.      get remote-file [ local-file ]                                    
  5058.                Retrieve the remote-file and store it on the local      
  5059.                machine. If the local file name is not specified,       
  5060.                it is given the same name it has on the remote          
  5061.                machine, subject to alteration by the current           
  5062.                case, ntrans, and nmap settings. The current            
  5063.                settings for type, form, mode, and structure are        
  5064.                used while transferring the file.                       
  5065.                                                                        
  5066.      glob      Toggle filename expansion for mdelete, mget and         
  5067.                mput.  If globbing is turned off with glob, the         
  5068.                file name arguments are taken literally and not         
  5069.                expanded.  Globbing for mput is done as in csh(1).      
  5070.                For mdelete and mget, each remote file name is          
  5071.                expanded separately on the remote machine and the       
  5072.                lists are not merged.  Expansion of a directory         
  5073.                name is likely to be different from expansion of        
  5074.                the name of an ordinary file:  the exact result         
  5075.                depends on the foreign operating system and FTP         
  5076.                server, and can be previewed by doing                   
  5077.                "mls remote-files -".  NOTE:  mget and mput are         
  5078.                not meant to transfer entire directory subtrees of      
  5079.                files.  That can be done by transferring a tar(1)       
  5080.                archive of the subtree (in binary mode).                
  5081.                                                                        
  5082.      hash      Toggle number-sign (#) printing for each data
  5083.                block transferred. The size of a data block i
  5084.                1024 bytes.                                  
  5085.                                                                       
  5086.      help [ command ]                                                 
  5087.                Print a description of command.  With no argument,     
  5088.                ftp prints a list of the known commands.               
  5089.                                                                       
  5090.      lcd [ directory ]                                                
  5091.                Change the working directory on the local machine.     
  5092.                If no directory is specified, changes to the          
  5093.                user's home directory.                                          
  5094.      ls [ remote-directory ] [ local-file ]                          
  5095.                Print an abbreviated listing of the contents of a
  5096.                directory on the remote machine. If remote-           
  5097.                directory is left unspecified, the current working    
  5098.                directory is used. If no local file is specified,     
  5099.                the output is sent to the terminal.                   
  5100.                                                                      
  5101.      macdef macro-name                                               
  5102.                Define a macro.  Subsequent lines are stored as       
  5103.                the macro-name; a null line (consecutive        
  5104.                newline characters in a file or carriage returns      
  5105.                from the terminal) terminates macro input mode.       
  5106.                There is a limit of 16 macros and 4096 total          
  5107.                characters in all defined macros.  Macros remain      
  5108.                defined until a close command is executed.  The       
  5109.                macro processor interprets "$" and "\" as special     
  5110.                characters.  A "$" followed by a number (or           
  5111.                numbers) is replaced by the corresponding argument    
  5112.                on the macro invocation command line.  A "$"          
  5113.                followed by an "i" signals that macro processor       
  5114.                that the executing macro is to be looped. On the      
  5115.                first pass "$i" is replaced by the first argument     
  5116.                on the macro invocation command line, on the          
  5117.                second pass it is replaced by the second argument,    
  5118.                and so on.  A "\" followed by any character is        
  5119.                replaced by that character.  Use the "\" to           
  5120.                prevent special treatment of the "$".                 
  5121.                                                                      
  5122.      mdelete [ remote-files ]                                        
  5123.                Delete the specified files on the remote machine.     
  5124.                                                                      
  5125.      mdir remote-files local-file                                    
  5126.                Like dir, except multiple remote files may be         
  5127.                specified.  If interactive prompting is on, ftp       
  5128.                will prompt the user to verify that the last          
  5129.                argument is indeed the target local file for          
  5130.                receiving mdir output.                                
  5131.                                                                      
  5132.      mget remote-files                                                
  5133.                Expand the remote-files on the remote machine and      
  5134.                do a get for each file name thus produced.  See        
  5135.                glob for details on the filename expansion.            
  5136.                Resulting file names will then be processed            
  5137.                according to case, ntrans, and nmap settings.          
  5138.                Files are transferred into the local working           
  5139.                directory, which can be changed with                   
  5140.                "lcd directory"; new local directories can be          
  5141.                created with "! mkdir directory".                      
  5142.                                                                       
  5143.      mkdir directory-name                                             
  5144.                Make a directory on the remote machine.                
  5145.                                                                       
  5146.      mls remote-files local-file                                       
  5147.                Like ls, except multiple remote files may be            
  5148.                specified.  If interactive prompting is on, ftp         
  5149.                will prompt the user to verify that the last            
  5150.                argument is indeed the target local file for            
  5151.                receiving mls output.                                   
  5152.                                                                        
  5153.      mode [ mode-name ]                                                
  5154.                Set the file transfer mode to mode-name.  The           
  5155.                default mode is stream.                                 
  5156.                                                                        
  5157.      mput local-files                                                  
  5158.                Expand wild cards in the list of local files given      
  5159.                as arguments and do a put for each file in the         
  5160.                resulting list.  See glob for details of filename      
  5161.                expansion.  Resulting file names will then be          
  5162.                processed according to ntrans and nmap settings.       
  5163.                                                                       
  5164.      nmap [ inpattern outpattern ]                                     
  5165.                Set or unset the filename mapping mechanism.  If        
  5166.                no arguments are specified, the filename mapping        
  5167.                mechanism is unset.  If arguments are specified,        
  5168.                remote filenames are mapped during mput commands        
  5169.                and put commands issued without a specified remote      
  5170.                target filename.  If arguments are specified,           
  5171.                local filenames are mapped during mget commands         
  5172.                and get commands issued without a specified local       
  5173.                target filename.  This command is useful when           
  5174.                connecting to a non-UNIX remote computer with           
  5175.                different file naming conventions or practices.         
  5176.                The mapping follows the pattern set by inpattern        
  5177.                and outpattern.  inpattern is a template for            
  5178.                incoming filenames (which may have already been         
  5179.                processed according to the ntrans and case              
  5180.                settings).  Variable templating is accomplished by      
  5181.                including the sequences "$1", "$2", ..., "$9" in        
  5182.                inpattern.  Use "\" to prevent this special             
  5183.                treatment of the "$" character.  All other              
  5184.                characters are treated literally, and are used to       
  5185.                determine the nmap inpattern variable values.  For      
  5186.                example, given inpattern $1.$2 and the remote file      
  5187.                name mydata.data, $1 would have the value mydata,       
  5188.                and $2 would have the value data.  The outpattern       
  5189.                determines the resulting mapped filename.  The          
  5190.                sequences "$1", "$2", ..., "$9" are replaced by         
  5191.                any value resulting from the inpattern template.        
  5192.                The sequence "$0" is replaced by the original           
  5193.                filename.  Additionally, the sequence                   
  5194.                "[seq1,seq2]" is replaced by seq1 if seq1 is not a
  5195.                null string; otherwise it is replaced by seq2.          
  5196.                For example, the command "nmap $1.$2.$3                 
  5197.                [$1,$2].[$2,file]" would yield the output filename      
  5198.                myfile.data for input filenames myfile.data and         
  5199.                myfile.data.old, myfile.file for the input              
  5200.                filename myfile, and myfile.myfile for the input        
  5201.                filename .myfile.  Spaces may be included in            
  5202.                outpattern, as in the example:                          
  5203.                                                                        
  5204.                     nmap $1 | sed "s/  *$//" > $1                      
  5205.                                                                        
  5206.                Use the "\" character to prevent special treatment      
  5207.                of the "$", "[", "]", and "," characters.               
  5208.                                                                        
  5209.      ntrans [ inchars [ outchars ] ]                                   
  5210.                Set or unset the filename character translation         
  5211.                mechanism.  If no arguments are specified, the          
  5212.                filename character translation mechanism is unset.      
  5213.                If arguments are specified, characters in remote        
  5214.                filenames are translated during mput commands and       
  5215.                put commands issued without a specified remote          
  5216.                target filename.  If arguments are specified,           
  5217.                characters in local filenames are translated            
  5218.                during mget commands and get commands issued            
  5219.                without a specified local target filename.  This        
  5220.                command is useful when connecting to a non-UNIX         
  5221.                remote computer with different file naming              
  5222.                conventions or practices.  Characters in a
  5223.                filename matching a character in inchars are            
  5224.                replaced with the corresponding character in            
  5225.                outchars.  If the character's position in inchars       
  5226.                is longer than the length of outchars, the              
  5227.                character is deleted from the file name.                
  5228.                                                                        
  5229.      open host [ port ]                                                
  5230.                Establish a connection to the specified host's FTP      
  5231.                server. An optional port number can be supplied,        
  5232.                in which case, ftp attempts to contact an FTP           
  5233.                server at that port. If the auto-login option is        
  5234.                on (default), ftp also attempts to automatically        
  5235.                log the user in to the FTP server (see below).          
  5236.                                                                        
  5237.      prompt    Toggle interactive prompting. Interactive               
  5238.                prompting occurs during multiple file transfers to      
  5239.                allow the user to selectively retrieve or store         
  5240.                files. If prompting is turned off (default), any        
  5241.                mget or mput transfers all files and mdelete will       
  5242.                delete all files.                                       
  5243.                                                                        
  5244.  
  5245.  
  5246.  
  5247.  
  5248.  
  5249.  
  5250.      proxy ftp-command                                                 
  5251.                Execute an ftp command on a secondary control           
  5252.                connection.  This command allows simultaneous           
  5253.                connection to two remote FTP servers for                
  5254.                transferring files between the two servers.  The        
  5255.                first proxy command should be an open, to               
  5256.                establish the secondary control connection.  Enter      
  5257.                the command "proxy ?" to see other ftp commands         
  5258.                executable on the secondary connection.  The            
  5259.                following commands behave differently when              
  5260.                prefaced by proxy:  open will not define new            
  5261.                macros during the auto-login process, close will        
  5262.                not erase existing macro definitions, get and mget      
  5263.                transfer files from the host on the primary             
  5264.                control connection to the host on the secondary         
  5265.                control connection, and put, mput, and append           
  5266.                transfer files from the host on the secondary           
  5267.                control connection to the host on the primary           
  5268.                control connection.  Third party file transfers         
  5269.                depend upon support of the FTP protocol PASV            
  5270.                command by the server on the secondary control          
  5271.                connection.                                             
  5272.                                                                        
  5273.      put local-file [ remote-file ]                                    
  5274.                Store a local file on the remote machine. If            
  5275.                remote-file is left unspecified, the local file         
  5276.                name is used in naming the remote file, after           
  5277.                processing according to any ntrans or nmap              
  5278.                settings.  File transfer uses the current settings      
  5279.                for type, format, mode, and structure.                  
  5280.                                                                        
  5281.      pwd       Print the name of the current working directory on      
  5282.                the remote machine.                                     
  5283.                                                                        
  5284.      quit      A synonym for bye.                                      
  5285.                                                                        
  5286.      quote arg1 arg2 ...                                               
  5287.                The arguments specified are sent, verbatim, to the      
  5288.                remote FTP server.                                      
  5289.                                                                        
  5290.      recv remote-file [ local-file ]                                   
  5291.                A synonym for get.                                      
  5292.                                                                        
  5293.      remotehelp [ command-name ]                                       
  5294.                Request help from the remote FTP server. If a
  5295.                command-name is specified, it is supplied to the       
  5296.                server as well.                                        
  5297.                                                                       
  5298.      rename [ from ] [ to ]                                           
  5299.                Rename, on the remote machine, the file from to        
  5300.                the file to.                                           
  5301.                                                                       
  5302.      reset     Clear reply queue.  This command re-synchronizes       
  5303.                command/reply sequencing with the remote FTP           
  5304.                server.  Resynchronization may be necessary            
  5305.                following a violation of the FTP protocol by the       
  5306.                remote server.                                         
  5307.                                                                       
  5308.      rmdir directory-name                                             
  5309.                Delete a directory on the remote machine.              
  5310.                                                                       
  5311.      runique   Toggle storing of files on the local system with       
  5312.                unique filenames.  If a file already exists with a
  5313.                name equal to the target local filename for a get       
  5314.                or mget command, a ".1" is appended to the name.        
  5315.                If the resulting name matches another existing          
  5316.                file, a ".2" is appended to the original name.  If      
  5317.                this process continues up to ".99", an error            
  5318.                message is printed, and the transfer does not take      
  5319.                place.  The generated unique filename will be           
  5320.                reported.  Note that runique will not affect local      
  5321.                files generated from a shell command (see below).       
  5322.                The default value is off.                               
  5323.                                                                        
  5324.      send local-file [ remote-file ]                                   
  5325.                A synonym for put.                                      
  5326.                                                                        
  5327.      sendport  Toggle the use of PORT commands. By default, ftp        
  5328.                attempts to use a PORT command when establishing a
  5329.                connection for each data transfer. The use of PORT      
  5330.                commands can prevent delays when performing             
  5331.                multiple file transfers.  If the PORT command           
  5332.                fails, ftp uses the default data port. When the         
  5333.                use of PORT commands is disabled, no attempt is         
  5334.                made to use them for each data transfer. This is        
  5335.                useful for certain FTP implementations that do          
  5336.                ignore PORT commands but wrongly indicate they          
  5337.                have been accepted.                                     
  5338.                                                                        
  5339.      status    Show the current status of ftp.                          
  5340.                                                                         
  5341.      struct [ struct-name ]                                             
  5342.                Set the file transfer structure to struct-name.          
  5343.                The default structure is stream.                         
  5344.                                                                         
  5345.      sunique   Toggle storing of files on remote machine under        
  5346.                unique file names.  Remote FTP server must support     
  5347.                the FTP protocol STOU command for successful           
  5348.                completion.  The remote server will report a
  5349.                unique name.  Default value is off.                    
  5350.                                                                       
  5351.      tenex     Set the file transfer type to that needed to talk      
  5352.                to TENEX machines.                                     
  5353.                                                                       
  5354.      trace     Toggle packet tracing.                                 
  5355.                                                                       
  5356.      type [ type-name ]                                               
  5357.                Set the file transfer type to type-name.  If no        
  5358.                type-name is specified, the current type is            
  5359.                printed. The default type is network ascii.            
  5360.                                                                       
  5361.      user-name [ password ] [ account ]                          
  5362.                The user identifies him/herself to the remote FTP      
  5363.                server. If the password is not specified and the       
  5364.                server requires it, ftp prompts the user for it        
  5365.                (after disabling local echo).  If an account field     
  5366.                is not specified, and the FTP server requires it,      
  5367.                the user is prompted for it. If an account field       
  5368.                is specified, an account command will be relayed       
  5369.                to the remote server after the login sequence is       
  5370.                completed if the remote server did not require it      
  5371.                for logging in.  Unless ftp is invoked with            
  5372.                "auto-login" disabled, this process is done            
  5373.                automatically on initial connection to the FTP         
  5374.                server.                                                
  5375.                                                                       
  5376.      verbose   Toggle verbose mode. In verbose mode, all              
  5377.                responses from the FTP server are displayed to the     
  5378.                user. In addition, if verbose is on, when a file       
  5379.                transfer completes, statistics regarding the           
  5380.                efficiency of the transfer are reported. By            
  5381.                default, verbose is on.                                
  5382.                                                                       
  5383.      ? [ command ]                                                    
  5384.                A synonym for help.                                    
  5385.                                                                       
  5386.      Command arguments that have embedded spaces can be quoted        
  5387.      with double quote (") marks.                                     
  5388.                                                                       
  5389. ABORTING A FILE TRANSFER                                              
  5390.      To abort a file transfer, use the terminal interrupt key         
  5391.      (usually <ctrl>C).  Sending transfers will be immediately        
  5392.      halted.  Receiving transfers will be halted by sending a FTP     
  5393.      protocol ABOR command to the remote server, and discarding       
  5394.      any further data received.  The speed at which this is           
  5395.      accomplished depends upon the remote server's support for        
  5396.      ABOR processing.  If the remote server does not support the      
  5397.      ABOR command, an ftp> prompt will not appear until the           
  5398.      remote server has completed sending the requested file.          
  5399.                                                                       
  5400.      The terminal interrupt key sequence will be ignored when ftp     
  5401.      has completed any local processing and is awaiting a reply       
  5402.      from the remote server.  A long delay in this mode may           
  5403.      result from the ABOR processing described above, or from         
  5404.      unexpected behavior by the remote server, including              
  5405.      violations of the FTP protocol.  If the delay results from       
  5406.      unexpected remote server behavior, the local ftp program         
  5407.      must be killed by hand.                                          
  5408.                                                                       
  5409. FILE NAMING CONVENTIONS                                               
  5410.      Files specified as arguments to ftp commands are processed       
  5411.      according to the following rules.                                
  5412.                                                                       
  5413.      1.   If the file name is -, the standard input (for reading)     
  5414.           or the standard output (for writing) is used.               
  5415.                                                                        
  5416.      2.   If the first character of the file name is a bar |, the      
  5417.           remainder of the argument is interpreted as a shell          
  5418.           command.  ftp then forks a shell, using popen(3S) with       
  5419.           the argument supplied, and reads (writes) from the           
  5420.           stdout (stdin).  If the shell command includes spaces,       
  5421.           the argument must be quoted; for example, "| ls -lt". A
  5422.           particularly useful example of this mechanism is            
  5423.           "dir | more".                                               
  5424.                                                                       
  5425.      3.   Failing the above checks, if globbing is enabled, local     
  5426.           file names are expanded according to the rules used in      
  5427.           the csh(1); see the glob command.  If the ftp command       
  5428.           expects a single local file (e.g., put), only the first     
  5429.           filename generated by the globbing operation is used.       
  5430.                                                                       
  5431.      4.   For mget commands and get commands with unspecified         
  5432.           local file names, the local filename is the remote          
  5433.           filename, which may be altered by a case, ntrans, or        
  5434.           nmap setting.  The resulting filename may then be           
  5435.           altered if runique is on.                                   
  5436.                                                                       
  5437.      5.   For mput commands and put commands with unspecified         
  5438.           remote file names, the remote filename is the local         
  5439.           filename, which may be altered by a ntrans or nmap          
  5440.           setting.  The resulting filename may then be altered by     
  5441.           the remote server if sunique is on.                         
  5442.                                                                       
  5443. FILE TRANSFER PARAMETERS                                              
  5444.      The FTP specification identifies many parameters that can        
  5445.      affect a file transfer. The type can be one of ascii, image      
  5446.      (binary), ebcdic, and local byte size (for PDP-10's and          
  5447.      PDP-20's mostly).  ftp supports the ascii and image types of     
  5448.      file transfer, plus local byte size 8 for tenex mode             
  5449.      transfers.                                                       
  5450.                                                                       
  5451.      ftp supports only the default values for the remaining file      
  5452.      transfer parameters:  mode, form, and struct.                    
  5453.  
  5454.  
  5455.  
  5456.  
  5457.                                                                       
  5458. OPTIONS                                                                
  5459.      Options can be specified at the command line, or to the           
  5460.      command interpreter.                                              
  5461.                                                                        
  5462.      The -v (verbose on) option forces ftp to show all responses       
  5463.      from the remote server, as well as report on data transfer        
  5464.      statistics.                                                       
  5465.                                                                        
  5466.      The -n option restrains ftp from attempting "auto-login"          
  5467.      upon initial connection.  If auto-login is enabled, ftp           
  5468.      checks the netrc file in the user's home directory for an         
  5469.      entry describing an account on the remote machine. If no          
  5470.      entry exists, ftp will prompt for the remote machine login        
  5471.      name (default is the user identity on the local machine),         
  5472.      and, if necessary, prompt for a password and an account with      
  5473.      which to login.                                                   
  5474.                                                                       
  5475.      The -i option turns off interactive prompting during             
  5476.      multiple file transfers.                                         
  5477.                                                                       
  5478.      The -d option enables debugging.                                 
  5479.                                                                       
  5480.      The -g option disables file name globbing.                       
  5481.                                                                       
  5482. THE .netrc FILE                                                       
  5483.      The .netrc file contains login and initialization                
  5484.      information used by the "auto-login" process.  It resides in     
  5485.      the user's home directory.  The following tokens are             
  5486.      recognized; they may be separated by spaces, tabs, or new-       
  5487.      lines:                                                           
  5488.                                                                       
  5489.      machine name                                                     
  5490.           Identify a remote machine name.  The auto-login process     
  5491.           searches the .netrc file for a machine token that           
  5492.           matches the remote machine specified on the ftp command     
  5493.           line or as an open command argument.  Once a match is       
  5494.           made, the subsequent .netrc tokens are processed,           
  5495.           stopping when the end of file is reached or another         
  5496.           machine token is encountered.                               
  5497.                                                                       
  5498.      login name                                                       
  5499.           Identify a user on the remote machine.  If this token       
  5500.           is present, the "auto-login" process will initiate a
  5501.           login using the specified name.                             
  5502.  
  5503.  
  5504.  
  5505.  
  5506.  
  5507.  
  5508.  
  5509.                                                                       
  5510.      password string                                                  
  5511.           Supply a password.  If this token is present, the           
  5512.           "auto-login" process will supply the specified string       
  5513.           if the remote server requires a password as part of the     
  5514.           login process.  Note that if this token is present in       
  5515.           the .netrc file, ftp will abort the "auto-login"            
  5516.           process if the .netrc is readable by anyone besides the     
  5517.           user.                                                       
  5518.                                                                       
  5519.      account string                                                   
  5520.           Supply an additional account password.  If this token       
  5521.           is present, the "auto-login" process will supply the        
  5522.           specified string if the remote server requires an           
  5523.           additional account password, or the "auto-login"            
  5524.           process will initiate an ACCT command if it does not.       
  5525.                                                                       
  5526.      macdef name                                                      
  5527.           Define a macro.  This token functions like the ftp          
  5528.           macdef command functions.  A macro is defined with the      
  5529.           specified name; its contents begin with the next .netrc     
  5530.           line and continue until a null line (consecutive new-       
  5531.           line characters) is encountered.  If a macro named init     
  5532.           is defined, it is automatically executed as the last        
  5533.           step in the "auto-login" process.                           
  5534.                                                                       
  5535. SEE ALSO                                                              
  5536.      csh(1).                                                          
  5537.      ftpd(1M) in the UMAX V Administrator's Reference Manual.         
  5538.                                                                       
  5539. BUGS                                                                  
  5540.      Correct execution of many commands depends upon proper           
  5541.      behavior by the remote server.                                   
  5542.                                                                       
  5543.      An error in the treatment of carriage returns in the 4.2BSD      
  5544.      UNIX ASCII-mode transfer code has been corrected.  This          
  5545.      correction may result in incorrect transfers of binary files     
  5546.      to and from 4.2BSD servers using the ascii type.  Avoid this     
  5547.      problem by using the binary image type.
  5548. APPENDIX C - C Compiler
  5549.  
  5550.  
  5551. NAME                                                                   
  5552.      cc - C compiler                                                   
  5553.                                                                        
  5554. SYNOPSIS                                                               
  5555.      cc [ option ] ... file ...                                        
  5556.                                                                        
  5557. DESCRIPTION                                                            
  5558.      The cc command invokes the C language compiler. This C            
  5559.      compiler is an advanced, optimizing compiler that accepts a
  5560.      complete implementation of the C programming language.  For       
  5561.      a more complete description of the compiler, see "C               
  5562.      Language" and "Compiler and C Language" in the UMAX V             
  5563.      Programmer's Guide.                                               
  5564.                                                                        
  5565.      Files with a .c suffix are taken to be C language source          
  5566.      programs.  The compiler processes every C language source         
  5567.      file to produce a corresponding object file with the same         
  5568.      file name and a .o suffix.  Files with a .s suffix are taken      
  5569.      to be assembly language source programs.  These are               
  5570.      assembled to produce a corresponding object file with the         
  5571.      same file name and a .o suffix.  Files with a suffix other        
  5572.      than .c and .s are assumed to be object files (usually            
  5573.      produced by an earlier compilation or assembly) or C-             
  5574.      compatible libraries.  These files, together with any object      
  5575.      code produced by the compiler, are linked in the order they       
  5576.      were specified to produce an executable program file named        
  5577.      a.out.                                                            
  5578.                                                                        
  5579.      If only one input file with a .c or .s suffix is supplied,        
  5580.      the compiler automatically deletes the object file output         
  5581.      produced from that input file after the executable program        
  5582.      file a.out is created.                                            
  5583.                                                                        
  5584.      The cc options that modify the behavior described above are:      
  5585.                                                                        
  5586.      -A       Cause ASCII assembler output to be generated and         
  5587.               automatically piped to the assembler.  The default       
  5588.               is for direct generation of object code. The -A          
  5589.               option is the same as the -q nodirect_code option.       
  5590.                                                                        
  5591.      -Bpath   Run the compiler program contained in pathccom.  If      
  5592.               -B is specified with no path, then the default path      
  5593.               is assumed to be /lib/o and the compiler program in      
  5594.               /lib/occom is run.  If no -B option is specified,        
  5595.               then the compiler program in /lib/ccom is run.           
  5596.                                                                        
  5597.      -c       Compile only. Produce object file output, even if        
  5598.               there was only one source file.                          
  5599.                                                                        
  5600.      -C       Retain comments during the macro preprocessor pass.             
  5601.  
  5602.      -Dname=def                                                        
  5603.               Define symbol name to be string def, as if by a
  5604.               #define statement.  If =def is omitted, define name     
  5605.               to be 1.                                                 
  5606.                                                                        
  5607.      -E       Run only the macro preprocessor, process only input      
  5608.               files with the .c suffix; send the result of this        
  5609.               pass to the standard output.                             
  5610.                                                                        
  5611.      -g       Generate special symbol table data for sdb(1) or         
  5612.               cdb(1) and pass the -g flag to the link editor.          
  5613.                                                                        
  5614.      -G       Cause object code to be directly generated by the        
  5615.               compiler, bypassing the intermediate steps of            
  5616.               producing assembly code and assembling it to             
  5617.               produce object code.  This is the default.  The -G       
  5618.               option is the same as the -q direct_code option.         
  5619.                                                                        
  5620.      -Idir    dir is a directory name.  Search for #include files      
  5621.               whose names do not begin with / first in the             
  5622.               directory containing the source file, then in dir,       
  5623.               and then in a list of standard defaults.  Multiple       
  5624.               -I options can establish a hierarchy of #include         
  5625.               file directories.                                        
  5626.                                                                        
  5627.      -o output                                                         
  5628.               Name the final, executable output file output            
  5629.               instead of a.out.  Note the space between the -o         
  5630.               and the file name.                                       
  5631.                                                                        
  5632.      -O       Perform optimizations which speed up the generated       
  5633.               code. Also, perform any space optimizations which        
  5634.               do not impact code speed.  See also the -q option.       
  5635.                                                                        
  5636.      -p       Prepare to generate an execution profile using           
  5637.               prof(1).  Include special profiling code that            
  5638.               counts how many times each routine is called.  If        
  5639.               linking occurs, use a special startup routine that       
  5640.               calls monitor(3C) and produces a mon.out file upon       
  5641.               termination.  Uses special profiling versions of         
  5642.               standard libraries found in /usr/lib/libp/lib*.a.        
  5643.               NOTE: use of the MARK macro (see prof(5)) requires        
  5644.               the -A option of cc.                                     
  5645.                                                                        
  5646.      -pg      Prepare to generate an execution profile using           
  5647.               gprof(1).  Include special profiling code that           
  5648.               counts how many times each function is called and        
  5649.               how much time is spent in each.  If linking occurs,      
  5650.               use a special startup function that calls                
  5651.               monstartup and produces a gmon.out file upon             
  5652.               termination.  Uses special profiling versions of         
  5653.               standard libraries found in /usr/lib/libp/lib*.a.        
  5654.               NOTE: Use of the MARK macro (see prof(5)) requires       
  5655.               the -A option of cc.                                     
  5656.                                                                        
  5657.      -P       Run all .c files through the preprocessing step,         
  5658.               putting the result in the corresponding output file      
  5659.               with a .i suffix.                                        
  5660.                                                                        
  5661.      -R       Make initialized variables shared and read-only (by      
  5662.               passing the -r option to the assembler).                 
  5663.                                                                        
  5664.      -S       Generate only assembly language output, putting it       
  5665.               in one or more files that have the source file name      
  5666.               and an .s suffix.                                       
  5667.                                                                       
  5668.      -Uname   Undefine symbol name to remove its default              
  5669.               definition.                                             
  5670.                                                                       
  5671.      -v       Report the names of all subprocesses invoked in the     
  5672.               compiled program, and their arguments.  This option     
  5673.               shows any files that are linked automatically and       
  5674.               the current compiler, assembler, and link editor        
  5675.               options.                                                
  5676.                                                                       
  5677.      -w       Suppress warning diagnostics.                           
  5678.                                                                       
  5679.      -Wc,arg                                                          
  5680.      -Wa,arg                                                          
  5681.      -Wl,arg  Pass option arg to the compiler (see "C Compiler        
  5682.               Internal Options" in the "Compiler and C Language"      
  5683.               chapter in the UMAX V Programmer's Guide),              
  5684.               assembler (see as(1)), or linker (see ld(1)),           
  5685.               respectively.                                           
  5686.                                                                       
  5687.      The following options are intended to provide more detailed      
  5688.      control over the generated code and action of the compiler.      
  5689.      In general, they should only be used for special situations.     
  5690.                                                                       
  5691.      -q qualifier                                                     
  5692.      -q qualifier=arg                                                 
  5693.               Modify the generated code of the compiler to            
  5694.               reflect various special requirements of a program.      
  5695.               Qualifiers include the following:                       
  5696.                                                                       
  5697.               align_text, noalign_text                                
  5698.                   Enable alignment of text segments on boundaries     
  5699.                   that allows the burst mode of systems equipped      
  5700.                   with APCs (Advanced Dual Processor Cards,           
  5701.                   utilizing the NS32332 CPU chip) to be most          
  5702.                   effectively used.  The default option is            
  5703.                   -q noalign_text, unless the -q optimize=time        
  5704.                   option is specified.                                
  5705.                                                                       
  5706.               xpc, apc, dpc                                           
  5707.                   Generate code optimized for a system equipped       
  5708.                   with XPCs (Extended Performance Dual Processor      
  5709.                   Cards, utilizing the NS32532 CPU chip), APCs        
  5710.                   (Advanced Dual Processor Cards, utilizing the       
  5711.                   NS32332 CPU chip), or DPCs (Dual Processor          
  5712.                   Cards, utilizing the NS32032 CPU chip).  If the     
  5713.                   -q xpc option is specified, then the                
  5714.                   preprocessor symbol ns32532 is defined and code     
  5715.                   optimal for the NS32532 is generated.  If the       
  5716.                   -q apc option is specified, then the                
  5717.                   preprocessor symbol ns32332 is defined and the      
  5718.                   -q align_text option is enabled.  If the -q dpc     
  5719.                   option is specified, then the preprocessor          
  5720.                   symbol ns32032 is defined and the                   
  5721.                   -q noalign_text option is enabled.  If neither      
  5722.                   -q xpc nor -q apc nor -q dpc is specified, then     
  5723.                   the default option is either -q xpc or -q apc       
  5724.                   or -q dpc , depending upon whether the system       
  5725.                   upon which the compiler is running is equipped      
  5726.                   with XPCs, APCs, or DPCs, respectively.  Code       
  5727.                   generated with these options will work on all       
  5728.                   XPCs, APCs, and DPCs.                               
  5729.                                                                       
  5730.               asmdir=prefix                                           
  5731.               crt0dir=prefix                                          
  5732.               lddir=prefix                                            
  5733.                   Overrides the defaults for the locations of         
  5734.                   as(1) (the assembler), the relevant startup         
  5735.                   routine (either crt0.o, mcrt0.o, or gcrt0.o),       
  5736.                   and ld(1) (the link editor).  The default           
  5737.                   values for these are asmdir=/bin/,                  
  5738.                   crt0dir=/lib/ (if the startup routine is crt0.o     
  5739.                   or mcrt0.o), crt0dir=/usr/lib/ (if the startup      
  5740.                   routine is gcrt0.o), and lddir=/bin/.               
  5741.                                                                       
  5742.               compiler_registers, nocompiler_registers                
  5743.                   Enable or disable compiler allocation of local      
  5744.                   variables to registers beyond those specified       
  5745.                   by register storage class specifications. The       
  5746.                   default option is -q compiler_registers.  The       
  5747.                   -q nocompiler_registers option should only be       
  5748.                   used when code is written to depend on the          
  5749.                   existence of non-register class variables in        
  5750.                   memory.
  5751.               direct_code, nodirect_code                              
  5752.                   Enable or disable the direct generation of code     
  5753.                   by the compiler. When enabled, the compiler         
  5754.                   will directly generate object code, bypassing       
  5755.                   the intermediate steps of producing assembly        
  5756.                   code and assembling it to produce the object        
  5757.                   code. The -q nodirect_code option (same as the      
  5758.                   -A option) should only be needed if the source      
  5759.                   file contains asm statements. The                   
  5760.                   -q direct_code option (same as the -G option)       
  5761.                   is enabled by default. The -q nodirect_code         
  5762.                   option is enabled if the -R option is               
  5763.                   specified.                                          
  5764.                                                                       
  5765.               enter_exits, noenter_exits                              
  5766.                   Generate enter and exit instructions at             
  5767.                   subroutine start and end.  Enter and exit           
  5768.                   instructions make stack tracing by debuggers        
  5769.                   possible.  The -q noenter_exits option is           
  5770.                   enabled by default, unless the -g option is         
  5771.                   used.                                               
  5772.                                                                       
  5773.               extensions, noextensions                                
  5774.               extensions=parallel                                     
  5775.               extensions=microtasking                                 
  5776.                   Specifies which language extensions will be         
  5777.                   recognized.  The -q extensions=parallel option      
  5778.                   specifies that extensions which support             
  5779.                   parallel programming are recognized.  This          
  5780.                   includes shared memory declarations and in-line     
  5781.                   code generation for spin lock routines.             
  5782.                   Consult the section "C Parallel Programming         
  5783.                   Extensions" in Chapter 18, Compiler and C           
  5784.                   Language in the UMAX V Programmer's Guide.  The      
  5785.                   -q extension=microtasking option specifies that      
  5786.                   extensions which support microtasking are            
  5787.                   recognized.  This includes the                       
  5788.                   -q extension=parallel extensions, and also           
  5789.                   specifies that the microtasking library and an       
  5790.                   alternate version of crt0.o are to be used by        
  5791.                   the load step.  The -q extensions option is          
  5792.                   equivalent to -q extension=microtasking.  The        
  5793.                   default option is -q noextensions.                   
  5794.               limitfregs, nolimitfregs                                 
  5795.                   Use or don't use the new NS32532 double              
  5796.                   precision floating point registers f1, f3, f5,       
  5797.                   f7. This flag is valid only in conjunction with      
  5798.                   the -q xpc flag. The default value for this          
  5799.                   flag is -q limitfregs (the new registers are         
  5800.                   not used). The double precision registers f1,        
  5801.                   f3, f5, f7 do not exist on APCs and DPCs, and        
  5802.                   code that uses these registers will not work on      
  5803.                   APCs and DPCs.                                       
  5804.                                                                        
  5805.               includes, noincludes                                     
  5806.                   Look or don't look for C language include files      
  5807.                   in the standard directory /usr/include.              
  5808.                   -q noincludes specifies there is no standard         
  5809.                   location for the include files.  The default         
  5810.                   value is -q includes.                                
  5811.                                                                        
  5812.               long_case, nolong_case                                   
  5813.                   Enable or disable the generation of case             
  5814.                   statements using a full four byte displacement.      
  5815.                   The -q nolong_case option is the default,            
  5816.                   allowing case statements to span 8 Kilobytes.        
  5817.                   The -q long_case option allows case statements       
  5818.                   to span 16 Megabytes. This should only be            
  5819.                   needed in unusual circumstances.                     
  5820.                                                                        
  5821.               long_jump, nolong_jump                                   
  5822.                   Enable or disable the generation of jumps with       
  5823.                   four byte displacements when the assembler is        
  5824.                   unable to resolve them in 1 byte.  This option       
  5825.                   only has effect when direct code generation is       
  5826.                   not enabled.  The default option,                    
  5827.                   -q nolong_jump, allows branches to span up to        
  5828.                   _8 Kilobytes.  The -q long_jump option will          
  5829.                   allow branches to span up to _16 Megabytes.          
  5830.                                                                        
  5831.               loops, noloops                                           
  5832.                   Enable or disable loop optimizations. These          
  5833.                   optimizations include loop-invariant hoisting        
  5834.                   and strength reduction. The default option is        
  5835.                   -q noloops.                                          
  5836.               optimize, nooptimize                                     
  5837.       optimize=none,optimize=standard,optimize=time,optimize=space     
  5838.                   Specify the level of optimization.  The              
  5839.                   -q optimize option is equivalent to the              
  5840.                   -q optimize=standard.  The -q nooptimize option      
  5841.                   is equivalent to -q optimize=none.  The -O           
  5842.                   option is equivalent to -q optimize=standard.        
  5843.                   The -q optimize=standard option enables a set        
  5844.                   of optimizations that do not take an excessive       
  5845.                   time to generate and do not overly favor space       
  5846.                   over time or vice versa.  The -q optimize=time       
  5847.                   option enables optimizations which may take          
  5848.                   longer to recognize but should yield a program       
  5849.                   that takes minimal time.  This option enables        
  5850.                   -q align_text, -q loops, and -q novolatile. If       
  5851.                   any of these options are inappropriate, they         
  5852.                   may be overridden by the appropriate -q noxxx        
  5853.                   option.  The -q optimize=space option enables        
  5854.                   optimizations which may take longer to generate      
  5855.                   but should yield a program which takes minimal       
  5856.                   space.  This option enables                          
  5857.                   -q preload_constants and -q tail_merge.  The         
  5858.                   default option is -q optimize=none.                  
  5859.                                                                        
  5860.               preload_constants, nopreload_constants                   
  5861.                   Enable or disable the linking of constant            
  5862.                   values and addresses that are frequently             
  5863.                   referenced in the source code at the start of a
  5864.                   program.  This option saves space; it may save       
  5865.                   execution time if the constants and addresses        
  5866.                   are also referenced frequently during                
  5867.                   execution. The -q nopreload_constants option is      
  5868.                   the default; the -q preload_constants option is     
  5869.                   enabled by the -O option.                           
  5870.                                                                       
  5871.               reg_params, noreg_params                                
  5872.                   Pass the first two parameters to a subroutine       
  5873.                   in registers rather than on the stack.  The         
  5874.                   -q noreg_params option is the default.  The         
  5875.                   standard libraries provided with the system         
  5876.                   assume -q noreg_params and will not work with       
  5877.                   object files built with the -q reg_params           
  5878.                   option.                                             
  5879.                                                                       
  5880.               sbfixed, nosbfixed                                      
  5881.                   Enable or disable the use of the NS32000 sb         
  5882.                   register when generating immediate addresses.       
  5883.                   The -q sbfixed option is the default.               
  5884.               signed_bit_fields, nosigned_bit_fields                  
  5885.                   Enable or disable making bit fields in              
  5886.                   structures of type int, short, and char to be       
  5887.                   signed. The default option,                         
  5888.                   -q nosigned_bit_fields, is to make all fields       
  5889.                   unsigned.                                           
  5890.                                                                       
  5891.               small_enums, nosmall_enums                              
  5892.                   Enable or disable the allocation of each enum       
  5893.                   type as the smallest predefined type that can       
  5894.                   represent all of the values that are listed         
  5895.                   (that is values of type char, short, int,           
  5896.                   unsigned char, unsigned short, or unsigned that     
  5897.                   are used in the enum statement). The default        
  5898.                   option, -q nosmall_enums, allocates an enum         
  5899.                   type as an int.                                     
  5900.                                                                       
  5901.               standard_library, nostandard_library                    
  5902.                   Allows the compiler to replace calls to             
  5903.                   standard libc routines with equivalent in-line      
  5904.                   code.  The default option is                        
  5905.                   -q nostandard_library, unless the                   
  5906.                   -q optimize=time option is specified.               
  5907.                                                                       
  5908.               tail_merge, notail_merge                                
  5909.                   Enable or disable branch-tail merging, an           
  5910.                   optimization which reduces code size by sharing     
  5911.                   common portions of then and else clauses or of      
  5912.                   case switches.   The -q tail_merge option is        
  5913.                   enabled by default, and disabled when -O is         
  5914.                   specified.                                          
  5915.                                                                       
  5916.               volatile, novolatile                                    
  5917.                   Disable or enable additional optimization on        
  5918.                   the assumption that memory never changes except     
  5919.                   as the result of explicit store operations. The     
  5920.                   default option, -q volatile, disables these         
  5921.                   optimizations.  The -q novolatile option should     
  5922.                   be used when all variables that can be modified     
  5923.                   asynchronously (e.g., by signal handlers) have      
  5924.                   type volatile.  Asynchronous modification could     
  5925.                   happen, for example, with signals, device           
  5926.                   drivers, and parallel processes accessing           
  5927.                   shared memory.  The current default is              
  5928.                   -q novolatile.  In the future, the goal is to       
  5929.                   have -q volatile the default value.                 
  5930. FILES                                                                 
  5931.      file.c              input file                                   
  5932.      file.o              object file                                  
  5933.      a.out               linked output                                
  5934.      /lib/ccom           compiler                                     
  5935.      /lib/occom          backup compiler                              
  5936.      /lib/crt0.o         runtime startoff                             
  5937.      /lib/mcrt0.o        startoff for profiling                       
  5938.      /lib/libc.a         standard library, see intro(3)                
  5939.      /usr/libp/lib*.a    profiling libraries, see intro(3)             
  5940.      /usr/include        standard directory for #include files         
  5941.      mon.out             file produced for analysis by prof(1)         
  5942.                                                                        
  5943. SEE ALSO                                                               
  5944.      adb(1), as(1), cdb(1), gprof(1), ld(1), prof(1), sdb(1),          
  5945.      a.out(4), monitor(3C).                                            
  5946.      cflow(1) in the UMAX V User's Reference Manual.                   
  5947.      "C Language" and "Compiler and C Language" in the UMAX V          
  5948.      cflow(1) in the UMAX V User's Reference Manual.                   
  5949.      "C Language" and "Compiler and C Language" in the UMAX V         
  5950.      Programmer's Guide.                                              
  5951.      B. W. Kernighan and D. M. Ritchie, The C Programming             
  5952.      Language.  Prentice-Hall, 1978.                                  
  5953.                                                                       
  5954. DIAGNOSTICS                                                           
  5955.      The diagnostics produced by C itself are intended to be          
  5956.      self-explanatory.  Occasional messages may be produced by        
  5957.      the assembler or link editor.                           
  5958. APPENDIX D - FORTRAN Compiler
  5959.  
  5960. $man f77                                                                  
  5961.                                                                        
  5962. NAME                                                                   
  5963.      f77 - Fortran-77 compiler                                         
  5964.                                                                        
  5965. SYNOPSIS                                                               
  5966.      f77 [ options ] file [ options ] [ files ] ...                    
  5967.                                                                        
  5968. DESCRIPTION                                                            
  5969.      The f77 compiler is an advanced, optimizing Fortran-77            
  5970.      compiler that accepts a complete implementation of the            
  5971.      standard Fortran language defined by ANSI standard X3.9-          
  5972.      1978.  It also has extensions to support VAX Fortran              
  5973.      functionality and parallel programming.  The  Fortran-77          
  5974.      compiler accepts any or none of the options described             
  5975.      following, and one or more input file names.  Files and           
  5976.      options can be mixed in any order.  Any differences between       
  5977.      4.2 and  V are noted in the text.                                 
  5978.                                                                        
  5979.      Files that have an f or F extension are taken to be               
  5980.      Fortran-77 language source programs.  The compiler processes      
  5981.      every Fortran-77 source file to produce a corresponding           
  5982.      object file with the same file name and an o extension.           
  5983.      Source files that have an F extension are passed through the      
  5984.      C language macro preprocessor before being compiled by the        
  5985.      f77 compiler.  Files that have an e extension are assumed to      
  5986.      be EFL (Extended Fortran Language) files, which are passed        
  5987.      through the efl preprocessor before being compiled by the         
  5988.      Fortran-77 compiler.  Files that have an r extension are          
  5989.      taken to be Ratfor files and passed through the ratfor            
  5990.      preprocessor before being compiled.  Files that have an s         
  5991.      extension are assumed to be assembly language source              
  5992.      programs.  These are assembled to produce a corresponding         
  5993.      object file with the same file name and an o extension.           
  5994.                                                                        
  5995.      Files with extensions other than f, F, e, r, and s are            
  5996.      assumed to be Fortran-compatible libraries, or object files       
  5997.      such as those files produced by an earlier compilation or         
  5998.      assembly.  These files, together with any object code             
  5999.      produced during the compilation, are loaded to produce an         
  6000.      executable program file named aout.                               
  6001.                                                                        
  6002.      If only one input file with an f, F, e, r, or s extension is      
  6003.      supplied, the compiler automatically deletes the object file      
  6004.      output produced from that input file after executable             
  6005.      program file aout has been created.                               
  6006.      All unrecognized options and all file names with extensions     
  6007.      other than .f, .F, .e, .r, .c are passed to the loader.  For    
  6008.      assembler options, see as(1); for loader options, see ld(1).    
  6009.      The f77 options are:                                            
  6010.                                                                      
  6011.      -Bprefix  Run the compiler program contained in file            
  6012.                prefixfcom.  If prefix is not given,                  
  6013.                /usr/lib/ofcom is the default compiler used.            
  6014.                                                                        
  6015.      -c        Compile only.  Produce object file output (even if      
  6016.                there was only one source file) and do not load         
  6017.                the program after compiling it.                         
  6018.                                                                        
  6019.      -Dname=def                                                        
  6020.                Define symbol name to be string def, when running       
  6021.                the C language preprocessor, as if by a #define         
  6022.                statement.  If =def is omitted, defines name to be      
  6023.                1 while running the C preprocessor.                     
  6024.                                                                        
  6025.      -Estring  Pass option(s) string to the efl preprocessor when      
  6026.                processing input files that have the e extension.       
  6027.                                                                        
  6028.      -F        Generate only Fortran language output from the          
  6029.                ratfor or efl preprocessor, placing it in a file        
  6030.                that has the source file name and the f extension,      
  6031.                but do not run the Fortran-77 compiler.                 
  6032.                                                                        
  6033.      -g        Generate special symbol table data for the sdb(1)       
  6034.                debugger (or the optional debugger), and pass the       
  6035.                -lg flag to the loader.                                 
  6036.                                                                        
  6037.      -Ipath    Include source files from the directory named path      
  6038.                when running the C language preprocessor.  When         
  6039.                compiling source files named with the F extension,      
  6040.                search for #include files (whose names do not           
  6041.                begin with /) first in the directory containing         
  6042.                the source file, then in the directory path, and        
  6043.                then in a list of standard defaults.  Multiple -I       
  6044.                options can establish a hierarchy of #include file      
  6045.                directories.                                            
  6046.                                                                        
  6047.      -i2       Make the default length of integer constants and        
  6048.                variables, and all logical quantities, be short.        
  6049.                Complementary option -i4 is the default, which          
  6050.                calls for long integer variables and constants.         
  6051.                                                                        
  6052.      -m        Apply the M4 macro preprocessor to each EFL or          
  6053.                Ratfor source file before passing it through the        
  6054.                efl or ratfor preprocessor.                             
  6055.      -O        Perform optimizations that speed up the generated       
  6056.                code; also perform any space optimizations that do      
  6057.                not impact code speed.  See also the -q qualifier       
  6058.                options.                                                
  6059.                                                                        
  6060.      -o output Name the final, executable output file output           
  6061.                rather than aout.                                       
  6062.                                                                        
  6063.      -onetrip  Generate object code that executes the range of         
  6064.                every do loop at least once, even if the initial        
  6065.                value of the loop index exceeds the limit value.        
  6066.                                                                        
  6067.      -p        Prepare to generate an execution profile using          
  6068.                prof(1).  Include special profiling code that           
  6069.                counts how many times each routine is called.  If       
  6070.                loading occurs, use a special startup routine that      
  6071.                calls monitor(3) and produces a monout file upon        
  6072.                termination.  Use a special profiling library           
  6073.                instead of the standard C library.                      
  6074.                                                                        
  6075.      -pg       Generate an execution profile using gprof.              
  6076.                Include special profiling code that counts how          
  6077.                many times each routine is called.  If loading          
  6078.                occurs, use a special startup routine that calls        
  6079.                monitor(3) and produces one or more gmon.pid upon       
  6080.                termination.  A profiling version of the standard      
  6081.                library is used.                                       
  6082.                                                                       
  6083.      -R        Make initialized variables shared and read-only        
  6084.                (by passing the -r option to the assembler).           
  6085.                                                                       
  6086.      -Rstring  Pass option(s) string to the ratfor preprocessor       
  6087.                when processing input files that have an r             
  6088.                extension.                                             
  6089.                                                                       
  6090.      -S        Generate assembly language output for each source      
  6091.                file, but do not assemble it.  Assembler output        
  6092.                for a source file with the extension f, F, e, r,       
  6093.                or c is put in a file with the same name and a s       
  6094.                extension.                                             
  6095.                                                                       
  6096.      -U        Do not convert uppercase letters to lowercase          
  6097.                letters.  By default Fortran programs are              
  6098.                converted to lowercase letters except within           
  6099.                character string constants.                            
  6100.                                                                       
  6101.      -u        Disable automatic data typing and, instead, make       
  6102.                the default type of a variable the undefined type.     
  6103.                                                                       
  6104.      -v        Report the names of all subprocesses invoked by        
  6105.                the compiler and their arguments.                      
  6106.                                                                       
  6107.      -w        Suppress warning diagnostics.                          
  6108.                                                                       
  6109.      -w66      Recognized only for compatibility with the             
  6110.                Portable Fortran-77 Compiler, which used this          
  6111.                option to suppress warnings about Fortran-66           
  6112.                features encountered during compilation.  The          
  6113.                Fortran-77 compiler does not flag language             
  6114.                elements that are unique to Fortran-66.                
  6115.                                                                       
  6116.      -W[a c l], arg                                                   
  6117.                Pass option arg to the assembler, compiler, or         
  6118.                linker, as specified respectively by -Wa, arg,         
  6119.                -Wc, arg, or -Wl, arg.  The internal options for       
  6120.                the  f77 compiler include implementation options       
  6121.                used to reconfigure the compiler for alien             
  6122.                operating environments, and debugging options used     
  6123.                for testing compiler software.  These options          
  6124.                should never be used in normal operation; they are     
  6125.                described in the Fortran-77 Manual.                    
  6126.                                                                       
  6127.      -q qualifier[=arg]                                               
  6128.                The qualifier options provide more detailed            
  6129.                control over the generated code and action of the      
  6130.                compiler.  They modify the generated code of the       
  6131.                compiler to reflect various special requirements       
  6132.                of a program, and in general should only be used       
  6133.                for special situations.  The qualifier options         
  6134.                deal with architecture, optimization selections,       
  6135.                file configuration, and Fortran language               
  6136.                extensions.  In this listing they are grouped by       
  6137.                category.  Both the qualifiers and any arguments,      
  6138.                which have compiler-defined values, can be             
  6139.                abbreviated to their minimum number of unique          
  6140.                characters.  The qualifiers are:                       
  6141.                                                                       
  6142.                     portable                                          
  6143.                apc, apc01, apc02, dpc, xpc[,2arg], host_is_target,    
  6144.                      These qualifiers select generation of code       
  6145.                      that is compatible with Multimax systems         
  6146.                      having APC DPC or XPC (National                  
  6147.                      Semiconductor NS32xxx-based) processor           
  6148.                      boards.  The default is to generate code         
  6149.                      appropriate for the machine on which the         
  6150.                      compiler is running.  (Differences between       
  6151.                      generated APC and DPC code are primarily in      
  6152.                      alignment optimization.)                         
  6153.                                                                       
  6154.                      apc   The apc qualifier selects APC01 code       
  6155.                            and the libm_apc.a math library.           
  6156.  
  6157.  
  6158.                                                                       
  6159.                      apc01 The apc01 qualifier is the same as the     
  6160.                            apc qualifier.  It is equivalent to        
  6161.                            the obsoleted switch combination,          
  6162.                            -q apc -q nofpa.                           
  6163.                                                                       
  6164.                      apc02 The apc02 qualifier selects APC02 code     
  6165.                            (with Cone instructions) and uses the      
  6166.                            libm_fpa.a math library.  This is          
  6167.                            equivalent to the obsoleted switch         
  6168.                            combination, -q apc -q fpa.                  
  6169.                                                                        
  6170.                      dpc   The dpc qualifier selects code              
  6171.                            optimized for a DPC system, and uses        
  6172.                            the libm_apc.a library.                     
  6173.                                                                        
  6174.                      xpc[,arg]                                         
  6175.                            The xpc qualifier generates code            
  6176.                            optimized for XPC systems, using the        
  6177.                            libm_xpc.a math library.  Since xpc         
  6178.                            permits access of 4 additional              
  6179.                            floating point (fp) registers and uses      
  6180.                            floating point instructions that do         
  6181.                            not exist for APC and DPC boards, code      
  6182.                            compiled using this option may not be       
  6183.                            portable to APC and DPC systems.  xpc       
  6184.                            accepts the arguments limitfregs and        
  6185.                            nolimitfregs.  -q xpc,limitfregs            
  6186.                            assures code compatibility with APC         
  6187.                            and DPC systems, selecting the              
  6188.                            libm_apc.a math library rather than         
  6189.                            libm_xpc.a and suppressing the usage        
  6190.                            of some double-precision floating           
  6191.                            point registers that are available to       
  6192.                            XPC systems; only 4 double-precision        
  6193.                            float registers are used.                   
  6194.                            -q xpc,nolimitfregs permits all             
  6195.                            floating point registers to be used,        
  6196.                            and uses the libm_xpc.a math library.       
  6197.                                                                        
  6198.                      host_is_target                                    
  6199.                            The host_is_target qualifier optimizes      
  6200.                            code for the system performing the          
  6201.                            compilation.  No attempt is made to         
  6202.                            preserve portability.  This is default      
  6203.                            behavior.                                   
  6204.  
  6205.  
  6206.  
  6207.  
  6208.  
  6209.  
  6210.                                                                        
  6211.                      portable                                          
  6212.                            The portable qualifier generates code       
  6213.                            that is portable across all Multimax        
  6214.                            APC, DPC, and XPC systems.  A
  6215.                            universal math library, libm_apc.a, is     
  6216.                            used.  Only optimizations that are         
  6217.                            explicitly portable are used.              
  6218.                            Produced code is portable to APC and       
  6219.                            DPC systems even if compiled on an XPC     
  6220.                            system, since only 4 double-precision      
  6221.                            float registers are used.                  
  6222.                                                                       
  6223.                align_text, noalign_text                               
  6224.                      Enable or disable alignment of text segments     
  6225.                      on boundaries to optimize burst mode on          
  6226.                      Multimax systems having APC s.  The default      
  6227.                      is noalign_text, unless optimize=time is         
  6228.                      enabled.                                         
  6229.                                                                       
  6230.                asmdir=prefix                                          
  6231.                      Use the assembler located in the prefixas        
  6232.                      file instead of the default assembler,           
  6233.                      /bin/as.                                         
  6234.                                                                       
  6235.                compiler_registers, nocompiler_registers               
  6236.                      Enable or disable compiler allocation of         
  6237.                      local variables to registers beyond those        
  6238.                      specified by register storage class              
  6239.                      specifications.  The default is                  
  6240.                      compiler_registers.  nocompiler_registers        
  6241.                      should only be used when code is written to      
  6242.                      depend on the existence of non-register          
  6243.                      class variables in memory.                       
  6244.                                                                       
  6245.                crt0dir=prefix                                         
  6246.                      Use the prefixcrt0.o startup file instead of     
  6247.                      the default startup file, /lib/crt0.o.           
  6248.                                                                       
  6249.                d_lines, nod_lines                                     
  6250.                      Enable or disable the recognition of any         
  6251.                      comment line, beginning with a D, as a code      
  6252.                      line.  The default is nod_lines.                 
  6253.  
  6254.  
  6255.  
  6256.  
  6257.  
  6258.  
  6259.  
  6260.  
  6261.  
  6262.                                                                       
  6263.                direct_code, nodirect_code                             
  6264.                      Enable or disable the direct generation of       
  6265.                      code by the compiler.  When enabled, the         
  6266.                      compiler directly generates object code,         
  6267.                      bypassing the intermediate steps of              
  6268.                      producing assembly code and assembling it to     
  6269.                      produce the object code.  The nodirect_code      
  6270.                      qualifier should only be needed if the           
  6271.                      source file contains asm statements.             
  6272.                      direct_code is enabled by default.               
  6273.                      nodirect_code is enabled if the -R option is     
  6274.                      specified.                                       
  6275.                                                                       
  6276.                extensions[=arg], noextensions                         
  6277.                      Enable or disable the specification of           
  6278.                      Fortran extensions.  The default qualifier       
  6279.                      is noextensions.  The available arguments         
  6280.                      are:                                              
  6281.                                                                        
  6282.                      berkeley_f77   Supports the standard UNIX         
  6283.                                     f77.  This is equivalent to       
  6284.                                     noextensions.                     
  6285.                                                                       
  6286.                      extended_f77   Supports an extension to f77      
  6287.                                     that allows Fortran programs      
  6288.                                     written for VAX/VMS to be         
  6289.                                     compiled on Multimax systems.     
  6290.                                     This is the default when the      
  6291.                                     -q extensions qualifier is        
  6292.                                     given without an argument.        
  6293.                                                                       
  6294.                      parallel       Recognizes the extensions         
  6295.                                     that support parallel             
  6296.                                     programming, including shared     
  6297.                                     memory declarations and           
  6298.                                     spinlocks in-line.  This does     
  6299.                                     not change the value of an        
  6300.                                     earlier specified                 
  6301.                                     berkeley_f77 or extended_f77      
  6302.                                     selection.                        
  6303.                                                                       
  6304.                lddir=prefix                                           
  6305.                      Use the link editor in prefixld instead of       
  6306.                      the default, /bin/ld.                            
  6307.  
  6308.  
  6309.  
  6310.  
  6311.  
  6312.  
  6313.  
  6314.                                                                       
  6315.                long_case, nolong_case                                 
  6316.                      Enable or disable the generation of case         
  6317.                      statements using a full four-byte                
  6318.                      displacement.  nolong_case is the default,       
  6319.                      allowing case statements to span 4               
  6320.                      Kilobytes.  long_case allows case statements     
  6321.                      to span 2 Megabytes.  This should only be        
  6322.                      needed in unusual circumstances.                 
  6323.                                                                       
  6324.                long_jump, nolong_jump                                 
  6325.                      Enable or disable the generation of jumps        
  6326.                      with four-byte displacements when the            
  6327.                      assembler is unable to resolve them in one       
  6328.                      byte.  The default, nolong_jump, allows          
  6329.                      branches to span up to _8 Kilobytes.             
  6330.                      long_jump allows branches to span up to _16      
  6331.                      Megabytes.  Direct code generation selects       
  6332.                      one-, two-, or four-byte displacement as         
  6333.                      appropriate, regardless of the setting of        
  6334.                      this option.                                     
  6335.                                                                       
  6336.                loops, noloops                                         
  6337.                      Enable or disable loop optimizations.  These     
  6338.                      optimizations include loop-invariant             
  6339.                      hoisting and strength reduction.  The            
  6340.                      default is noloops.                              
  6341.                                                                       
  6342.                optimize[=arg], nooptimize                             
  6343.                      Enable or disable different levels of            
  6344.                      optimization.  The default is optimize=none.     
  6345.                      The available arguments are:                     
  6346.                                                                       
  6347.                      none       Enable no special optimizations.      
  6348.                                 none is equivalent to nooptimize.     
  6349.                                                                       
  6350.                      space      Enable optimizations which may        
  6351.                                 take longer to generate but which     
  6352.                                 should produce a program that         
  6353.                                 requires minimal space.  This         
  6354.                                 argument also enables                 
  6355.                                 preload_constants and tail_merge.     
  6356.                                                                       
  6357.                      standard   Enable a set of optimizations         
  6358.                                 that do not take an excessive         
  6359.                                 amount of time to generate and        
  6360.                                 which do not favor space over         
  6361.                                 time (or vice versa).                 
  6362.  
  6363.  
  6364.  
  6365.  
  6366.  
  6367.                      time       Enable optimizations which may        
  6368.                                 take longer to recognize but          
  6369.                                 which should produce a program        
  6370.                                 that requires minimal execution       
  6371.                                 time.  This argument also enables     
  6372.                                 align_text, loops, and                
  6373.                                 novolatile.                           
  6374.                                                                       
  6375.                preload_constants, nopreload_constants                 
  6376.                      Enable or disable the loading of constant        
  6377.                      values and addresses that are frequently         
  6378.                      referenced in the source code at the start       
  6379.                      of a program.  This option saves space; it       
  6380.                      may save execution time if the constants and     
  6381.                      addresses are also referenced frequently         
  6382.                      during execution.  no_preload_constants is       
  6383.                      the default; preload_constants is enabled by     
  6384.                      the -O option.                                   
  6385.                                                                       
  6386.                single_lib, nosingle_lib                               
  6387.                      Enable or disable the use of single              
  6388.                      precision math routines for certain built-in     
  6389.                      functions when the functions are called with     
  6390.                      single precision arguments.  The single          
  6391.                      precision versions offer significantly           
  6392.                      increased speed with almost no reduction in      
  6393.                      accuracy.  single_lib is enabled by default.     
  6394.                                                                       
  6395.                tail_merge, notail_merge                               
  6396.                      Enable or disable branch-tail merging, an        
  6397.                      optimization that reduces code size by           
  6398.                      sharing common portions of then and else         
  6399.                      clauses or of case switches.  tail_merge is      
  6400.                      disabled by default.                             
  6401.                                                                       
  6402.                volatile, novolatile                                   
  6403.                      Enable or disable additional optimization on     
  6404.                      the assumption that memory never changes         
  6405.                      except as the result of explicit store           
  6406.                      operations.  The default is volatile, unless     
  6407.                      optimize=time is selected.  novolatile,          
  6408.                      which enables the optimizations, is              
  6409.                      available only when optimize=time is             
  6410.                      selected.  novolatile should only be used        
  6411.                      when it is clear that no variables can be        
  6412.                      modified asynchronously.  Asynchronous           
  6413.                      modification could happen, for example, with     
  6414.                      signals, device drivers, or parallel             
  6415.                      processes accessing shared memory.               
  6416.  
  6417.  
  6418.                                                                       
  6419. RESTRICTIONS                                                          
  6420.      The -q flag and its qualifier options replace the following      
  6421.      options, which are no longer supported:                          
  6422.                                                                       
  6423.      -A  Replaced by -q nodirect_code.                                
  6424.                                                                       
  6425.      -G  Replaced by -q direct_code.                                  
  6426.                                                                       
  6427.      -H  Replaced by -q notail_merge.                                 
  6428.                                                                       
  6429.      -J  Replaced by -q long_jump.                                    
  6430.                                                                       
  6431.      -T  Replaced by -q loops.                                        
  6432.                                                                       
  6433.      -V  Replaced by -q novolatile.                                   
  6434.                                                                       
  6435. FILES                                                                 
  6436.      ./fort[pid].?           temporary fortran process files          
  6437.      a.out                   loaded output file                       
  6438.      file.[fFresc]           input file                               
  6439.      file.o                  object file                              
  6440.   gmon.[pid]              file produced for analysis by monitor(3)    
  6441.      mon.out                 file produced for analysis by prof(1)    
  6442.      /lib/cpp                C preprocessor                           
  6443.      /lib/libc.a             C library                                
  6444.      /lib/cpp                C preprocessor                           
  6445.      /lib/libc.a             C library                                
  6446.      /usr/lib/fcom           Fortran compiler                         
  6447.      /usr/lib/libFBERK.a     combined libF77.a, libI77.a, and         
  6448.                              libU77.a library                         
  6449.      /usr/lib/libFBERK_p.a   profiling combined Berkeley function     
  6450.                              library                                  
  6451.      /usr/lib/libFORT.a      combined libFBERK.a and libX77.a
  6452.                              library                                  
  6453.      /usr/lib/libFORT_p.a    profiling combined extended Berkeley      
  6454.                              function                                 
  6455.      /usr/lib/libm_apc.a     standard NS32081 code math library       
  6456.      /usr/lib/libm_fpa.a     math library for APC02 systems with      
  6457.                              Cone processor                           
  6458.      /usr/lib/libm_xpc.a     XPC system math library (8 float-        
  6459.                              register, NS32381)                       
  6460.                                                                       
  6461. SEE ALSO                                                              
  6462.      as(1), cc(1), ld(1), m4(1), prof(1), sdb(1), cdb(1X),            
  6463.      efl(1F), fpr(1F) fsplit(1F) ratfor(1F), struct(1F),              
  6464.      intro(3F) epf(9F),                                               
  6465.       Fortran-77 Manual.                                              
  6466.                                                                       
  6467.      American National Standard Programming Language Fortran,         
  6468.      ANSI X3.9-1978.                                                  
  6469. APPENDIX E - lint
  6470.                                                                         
  6471. $man lint                                                             
  6472.                                                                       
  6473. NAME                                                                  
  6474.      lint - a C program checker                                       
  6475.                                                                       
  6476. SYNOPSIS                                                              
  6477.      lint [ option ] ... file ...                                     
  6478.                                                                       
  6479. DESCRIPTION                                                           
  6480.      lint attempts to detect features of the C program files that     
  6481.      are likely to be bugs, non-portable, or wasteful.  It also       
  6482.      checks type usage more strictly than the compilers.  Among       
  6483.      the things that are currently detected are unreachable           
  6484.      statements, loops not entered at the top, automatic              
  6485.      variables declared and not used, and logical expressions         
  6486.      whose value is constant.  Moreover, the usage of functions       
  6487.      is checked to find functions that return values in some          
  6488.      places and not in others, functions called with varying          
  6489.      numbers or types of arguments, and functions whose values        
  6490.      are not used or whose values are used but none returned.         
  6491.                                                                       
  6492.      Arguments whose names end with .c are taken to be C source       
  6493.      files.  Arguments whose names end with .ln are taken to be       
  6494.      the result of an earlier invocation of lint with either the      
  6495.      -c or the -o option used.  The .ln files are analogous to .o     
  6496.      (object) files that are produced by the cc(1) command when       
  6497.      given a .c file as input.  Files with other suffixes are         
  6498.      warned about and ignored.                                        
  6499.                                                                       
  6500.      lint will take all the .c, .ln, and llib-lx.ln (specified by     
  6501.      -lx) files and process them in their command line order.  By     
  6502.      default, lint appends the standard C lint library (llib-         
  6503.      lc.ln) to the end of the list of files.  However, if the -p      
  6504.      option is used, the portable C lint library (llib-port.ln)       
  6505.      is appended instead.  When the -c option is not used, the        
  6506.      second pass of lint checks this list of files for mutual         
  6507.      compatibility.  When the -c option is used, the .ln and the      
  6508.      llib-lx.ln files are ignored.                                    
  6509.                                                                       
  6510.      Any number of lint options may be used, in any order,            
  6511.      intermixed with file-name arguments.  The following options      
  6512.      are used to suppress certain kinds of complaints:                
  6513.                                                                       
  6514.      -a      Suppress complaints about assignments of long values     
  6515.              to variables that are not long.                          
  6516.                                                                       
  6517.      -b      Suppress complaints about break statements that          
  6518.              cannot be reached.  (Programs produced by lex(1) or      
  6519.              yacc(1) will often result in many such complaints.)      
  6520.                                                                       
  6521.      -h      Do not apply heuristic tests that attempt to intuit      
  6522.              bugs, improve style, and reduce waste.                   
  6523.                                                                       
  6524.      -u      Suppress complaints about functions and external         
  6525.              variables used and not defined, or defined and not       
  6526.              used.  (This option is suitable for running lint on      
  6527.              a subset of files of a larger program).                  
  6528.                                                                       
  6529.      -v      Suppress complaints about unused arguments in            
  6530.              functions.                                               
  6531.                                                                       
  6532.      -x      Do not report variables referred to by external          
  6533.              declarations but never used.                             
  6534.                                                                       
  6535.      The following arguments alter lint's behavior:                   
  6536.                                                                       
  6537.      -lx  Include additional lint library llib-lx.ln.  For            
  6538.           example, a lint version of the Math Library llib-lm.ln      
  6539.           can be included by inserting -lm on the command line.       
  6540.           This argument does not suppress the default use of          
  6541.           llib-lc.ln.  These lint libraries must be in the            
  6542.           assumed directory.  This option can be used to              
  6543.           reference local lint libraries and is useful in the         
  6544.           development of multi-file projects.                         
  6545.                                                                       
  6546.      -n   Do not check compatibility against either the standard      
  6547.           or the portable lint library.                               
  6548.                                                                       
  6549.      -p   Attempt to check portability to other dialects (IBM and     
  6550.           GCOS) of C.  Along with stricter checking, this option      
  6551.           causes all non-external names to be truncated to eight      
  6552.           characters and all external names to be truncated to        
  6553.           six characters and one case.                                
  6554.                                                                       
  6555.      -c   Cause lint to produce a .ln file for every .c file on       
  6556.           the command line.  These .ln files are the product of       
  6557.           lint's first pass only, and are not checked for inter-      
  6558.           function compatibility.                                     
  6559.                                                                       
  6560.      -o lib                                                           
  6561.           Cause lint to create a lint library with the name           
  6562.           llib-llib.ln.  The -c option nullifies any use of the       
  6563.           -o option.  The lint library produced is the input that     
  6564.           is given to lint's second pass.  The -o option simply       
  6565.           causes this file to be saved in the named lint library.     
  6566.           To produce a llib-llib.ln without extraneous messages,      
  6567.           use of the -x option is suggested.  The -v option is        
  6568.           useful if the source file(s) for the lint library are       
  6569.           just external interfaces (for example, the way the file     
  6570.           llib-lc is written).  These option settings are also        
  6571.           available through the use of "lint comments" (see           
  6572.           below).                                                     
  6573.                                                                       
  6574.      The -D, -U, and -I options of cc(1) and cpp(1) and the -g        
  6575.      and -O options of cc are also recognized as separate             
  6576.      arguments.  The -g and -O options are ignored, but, by           
  6577.      recognizing these options, lint's behavior is closer to that     
  6578.      of the cc command.  Other options are warned about and           
  6579.      ignored.  The pre-processor symbol "lint" is defined to          
  6580.      allow certain questionable code to be altered or removed for     
  6581.      lint.  Therefore, the symbol "lint" should be thought of as      
  6582.      a reserved word for all code that is planned to be checked       
  6583.      by lint.                                                         
  6584.                                                                       
  6585.      Certain conventional comments in the C source will change        
  6586.      the behavior of lint:                                            
  6587.                                                                       
  6588.      /*NOTREACHED*/                                                   
  6589.           at appropriate points stops comments about unreachable      
  6590.           code.  (This comment is typically placed just after         
  6591.           calls to functions like exit(2).)                           
  6592.                                                                       
  6593.      /*VARARGSn*/                                                     
  6594.           suppresses the usual checking for variable numbers of        
  6595.           arguments in the following function declaration.  The        
  6596.           data types of the first n arguments are checked; a
  6597.           missing n is taken to be 0.                                  
  6598.                                                                        
  6599.      /*ARGSUSED*/                                                      
  6600.           turns on the -v option for the next function.                
  6601.                                                                        
  6602.      /*LINTLIBRARY*/                                                   
  6603.           at the beginning of a file shuts off complaints about        
  6604.           unused functions and function arguments in this file.        
  6605.           This is equivalent to using the -v and -x options.           
  6606.                                                                        
  6607.      lint produces its first output on a per-source-file basis.        
  6608.      Complaints regarding included files are collected and             
  6609.      printed after all source files have been processed.               
  6610.      Finally, if the -c option is not used, information gathered       
  6611.      from all input files is collected and checked for                 
  6612.      consistency.  At this point, if it is not clear whether a
  6613.      complaint stems from a given source file or from one of its      
  6614.      included files, the source file name will be printed             
  6615.      followed by a question mark.                                     
  6616.  
  6617.  
  6618.  
  6619.  
  6620.  
  6621.  
  6622.  
  6623.  
  6624.                                                                       
  6625.      The behavior of the -c and the -o options allows for             
  6626.      incremental use of lint on a set of C source files.              
  6627.      Generally, one invokes lint once for each source file with       
  6628.      the -c option.  Each of these invocations produces a .ln         
  6629.      file which corresponds to the .c file, and prints all            
  6630.      messages that are about just that source file.  After all        
  6631.      the source files have been separately run through lint, it       
  6632.      is invoked once more (without the -c option), listing all        
  6633.      the .ln files with the needed -lx options.  This will print      
  6634.      all the inter-file inconsistencies.  This scheme works well      
  6635.      with make(1); it allows make to be used to lint only the         
  6636.      source files that have been modified since the last time the     
  6637.      set of source files were linted.                                 
  6638.                                                                       
  6639. FILES                                                                 
  6640.      /usr/lib/lint[12]        first and second passes                 
  6641.      /usr/lib/llib-lc.ln      declarations for C Library              
  6642.                               functions (binary format; source is     
  6643.                               in /usr/lib/llib-lc)                    
  6644.      /usr/lib/llib-port.ln    declarations for portable functions     
  6645.                               (binary format; source is in            
  6646.                               /usr/lib/llib-port)                     
  6647.      /usr/lib/llib-lm.ln      declarations for Math Library           
  6648.                               functions (binary format; source is     
  6649.                               in /usr/lib/llib-lm.ln)                 
  6650.      /usr/tmp/*lint*          temporaries                             
  6651.                                                                       
  6652. SEE ALSO                                                              
  6653.      cc(1), cpp(1), lex(1), make(1), yacc(1), tmpnam(3S).             
  6654.                                                                       
  6655. BUGS                                                                  
  6656.      exit(2), longjmp(3C), and other functions that do not return     
  6657.      are not understood; this causes various lies.                    
  6658. APPENDIX F - cb
  6659.  
  6660. $man cb                                                                 
  6661.                                                                         
  6662. NAME                                                                    
  6663.      cb - C program beautifier                                         
  6664.                                                                        
  6665. SYNOPSIS                                                               
  6666.      cb [ -s ] [ -j ] [ -l leng ] [ file ... ]                         
  6667.                                                                        
  6668. DESCRIPTION                                                            
  6669.      The cb comand reads C programs either from its arguments or       
  6670.      from the standard input, and writes them on the standard          
  6671.      output with spacing and indentation that display the              
  6672.      structure of the code.  Under default options, cb preserves       
  6673.      all user new-lines.                                               
  6674.                                                                        
  6675.      cb accepts the following options.                                 
  6676.                                                                        
  6677.      -s        Canonicalizes the code to the style of Kernighan        
  6678.                and Ritchie in The C Programming Language.              
  6679.                                                                        
  6680.      -j        Causes split lines to be put back together.             
  6681.                                                                        
  6682.       -l leng  Causes cb to split lines that are longer than           
  6683.                leng.                                                   
  6684.                                                                        
  6685. SEE ALSO                                                               
  6686.      cc(1).                                                            
  6687.      The C Programming Language.  Prentice-Hall, 1978.                 
  6688.                                                                        
  6689. BUGS                                                                   
  6690.      Punctuation that is hidden in preprocessor statements will        
  6691.      cause indentation errors.                                         
  6692. APPENDIX G - ar
  6693.  
  6694. $man ar                                                                  
  6695.                                                                        
  6696. NAME                                                                   
  6697.      ar - archive and library maintainer for portable archives         
  6698.                                                                        
  6699. SYNOPSIS                                                               
  6700.      ar key [ posname ] afile [ name ] ...                             
  6701.                                                                        
  6702. DESCRIPTION                                                            
  6703.      The ar command maintains groups of files combined into a
  6704.      single archive file.  Its main use is to create and update      
  6705.      library files as used by the link editor.  It can be used,      
  6706.      though, for any similar purpose.  The magic string and the      
  6707.      file headers used by ar consist of printable ASCII              
  6708.      characters.  If an archive is composed of printable files,      
  6709.      the entire archive is printable.                                
  6710.                                                                      
  6711.      When ar creates an archive, it creates headers in a format      
  6712.      that is portable across all machines.  The portable archive     
  6713.      format and structure is described in detail in ar(4).  The      
  6714.      archive symbol table (described in ar(4)) is used by the        
  6715.      link editor (ld(1)) to effect multiple passes over libraries    
  6716.      of object files in an efficient manner.  An archive symbol      
  6717.      table is only created and maintained by ar when there is at     
  6718.      least one object file in the archive.  The archive symbol       
  6719.      table is in a specially named file which is always the first    
  6720.      file in the archive.  This file is never mentioned or           
  6721.      accessible to the user.  Whenever the ar command is used to     
  6722.      create or update the contents of such an archive, the symbol    
  6723.      table is rebuilt.  The s option described below will force      
  6724.      the symbol table to be rebuilt. The symbol table holds a
  6725.      maximum of 20,000 symbols.                                       
  6726.                                                                       
  6727.      Unlike command options, the command key is a required part       
  6728.      of ar's command line.  The key (which may begin with a -) is     
  6729.      formed with one of the following letters:  drqtpmx.              
  6730.      Arguments to the key, alternatively, are made with one of        
  6731.      more of the following set:  vuaibcls.  posname is an archive     
  6732.      member name used as a reference point in positioning other       
  6733.      files in the archive.  afile is the archive file.  The names     
  6734.      are constituent files in the archive file.  The meanings of      
  6735.      the key characters are as follows:                               
  6736.                                                                       
  6737.      d    Delete the named files from the archive file.               
  6738.                                                                       
  6739.  
  6740.  
  6741.  
  6742.  
  6743.  
  6744.      r    Replace the named files in the archive file.  If the        
  6745.           optional character u is used with r, then only those        
  6746.           files with dates of modification later than the archive     
  6747.           files are replaced.  If an optional positioning             
  6748.           character from the set aib is used, then the posname        
  6749.           argument must be present and specifies that new files       
  6750.           are to be placed after (a) or before (b or i) posname.      
  6751.           Otherwise new files are placed at the end.                  
  6752.                                                                       
  6753.      q    Quickly append the named files to the end of the            
  6754.           archive file.  Optional positioning characters are          
  6755.           invalid.  The command does not check whether the added      
  6756.           members are already in the archive. This option is          
  6757.           useful to avoid quadratic behavior when creating a
  6758.           large archive piece-by-piece.  Unchecked, the file may      
  6759.           grow exponentially up to the second degree.                 
  6760.                                                                       
  6761.      t    Print a table of contents of the archive file.  If no       
  6762.           names are given, all files in the archive are tabled.       
  6763.           If names are given, only those files are tabled.            
  6764.                                                                       
  6765.      p    Print the named files in the archive.                       
  6766.                                                                       
  6767.      m    Move the named files to the end of the archive.  If a
  6768.           positioning character is present, then the posname          
  6769.           argument must be present and, as in r, specifies where      
  6770.           the files are to be moved.                                  
  6771.                                                                       
  6772.      x    Extract the named files.  If no names are given, all        
  6773.           files in the archive are extracted.  In neither case        
  6774.           does x alter the archive file.                              
  6775.                                                                       
  6776.      The meanings of the key arguments are as follows:                
  6777.                                                                       
  6778.      v    Give a verbose file-by-file description of the making       
  6779.           of a new archive file from the old archive and the          
  6780.           constituent files.  When used with t, give a long           
  6781.           listing of all information about the files.  When used      
  6782.           with x, precede each file with a name.                      
  6783.                                                                       
  6784.      c    Suppress the message that is produced by default when       
  6785.           afile is created.                                           
  6786.                                                                       
  6787.      l    Place temporary files in the local (current working)        
  6788.           directory, rather than in the default temporary             
  6789.           directory, /tmp.                                             
  6790.                                                                        
  6791.      s    Force the regeneration of the archive symbol table even      
  6792.           if ar is not invoked with a command which will modify        
  6793.           the archive contents.  This command is useful to             
  6794.           restore the archive symbol table after the strip(1)          
  6795.           command has been used on the archive.                                
  6796. SEE ALSO                                                               
  6797.      ld(1), lorder(1), strip(1), tmpnam(3S), a.out(4), ar(4).          
  6798.      "The Common Object File Format" in the UMAX V Programmer's        
  6799.      Guide.                                                            
  6800.                                                                        
  6801.  
  6802. BUGS                                                                   
  6803.      If the same file is mentioned twice in an argument list, it       
  6804.      may be put in the archive twice.                                  
  6805.                                                                        
  6806.  
  6807.                                                                                
  6808. NAME                                                                   
  6809.      ar - common archive file format                                   
  6810.                                                                        
  6811. DESCRIPTION                                                            
  6812.      The archive command ar(1) combines several files into one.        
  6813.      Archives are used mainly as libraries to be searched by the       
  6814.      link editor ld(1).                                                
  6815.                                                                        
  6816.      Each archive begins with the archive magic string:                
  6817.                                                                        
  6818.      #define  ARMAG     "!<arch>\n"   /* magic string */               
  6819.      #define  SARMAG    8             /* length of magic string */     
  6820.                                                                        
  6821.      Each archive that contains common object files (see               
  6822.      a.out(4)) includes an archive symbol table.  The link editor      
  6823.      ld uses the symbol table to determine which archive members       
  6824.      Each archive that contains common object files (see               
  6825.      a.out(4)) includes an archive symbol table.  The link editor      
  6826.      ld uses the symbol table to determine which archive members       
  6827.      must be loaded during the link edit process.  The archive         
  6828.      symbol table (if it exists) is always the first file in the       
  6829.      archive (but is never listed) and is automatically created        
  6830.      and updated by ar.                                                
  6831.                                                                        
  6832.      Following the archive magic string are the archive file           
  6833.      members.  Each file member is preceded by a file member           
  6834.      header in the following format:                                   
  6835.                                                                        
  6836.      #define ARFMAG            "`\n"  /* header trailer string */      
  6837.      struct  ar_hdr {                 /* file member header */         
  6838.              char ar_date[12];        /* file member date */           
  6839.                                       member name */                   
  6840.              char ar_gid[6];          /* file member group             
  6841.                                       identification */                
  6842.              char ar_mode[8];         /* file member mode              
  6843.                                       (octal) */                       
  6844.              char ar_size[10];        /* file member size */           
  6845.              char ar_fmag[2];         /* header trailer string */      
  6846.      };                                                                
  6847.                                                                        
  6848.      All information in the file member headers is in printable        
  6849.      ASCII .  The numeric information in the headers is stored as      
  6850.      decimal numbers (except for ar_mode, which is in octal).          
  6851.      Thus, if the archive contains printable files, the archive        
  6852.      itself is printable.                                              
  6853.  
  6854.                                                                        
  6855.  
  6856.  
  6857.  
  6858.  
  6859.      The ar_name field is blank-padded and terminated with a
  6860.      slash (/).  The ar_date field is the modification date of         
  6861.      the file at the time it is inserted into the archive.             
  6862.      Common format archives can be moved from system to system as      
  6863.      long as the portable archive command ar is used.                  
  6864.                                                                        
  6865.      Each archive file member begins on an even byte boundary; a
  6866.      newline is inserted between files if necessary.                  
  6867.      Nevertheless the size given reflects the actual size of the      
  6868.      file exclusive of padding.                                       
  6869.                                                                       
  6870.      Notice there is no provision for empty areas in an archive       
  6871.      file.                                                            
  6872.                                                                       
  6873.      If the archive symbol table exists, the first file in the        
  6874.      archive has a zero length name (that is, ar_name[0] == '/').     
  6875.      The contents of this file are:                                   
  6876.                                                                       
  6877.           The number of symbols.  Length: 4 bytes.                    
  6878.                                                                       
  6879.           The array of offsets into the archive file.  Length: 4      
  6880.           bytes * "the number of symbols".                            
  6881.                                                                       
  6882.           The name string table.  Length:  ar_size - (4 bytes *       
  6883.           ("the number of symbols" + 1)).                             
  6884.                                                                       
  6885.      The string table contains exactly as many null-terminated        
  6886.      strings as there are elements in the offsets array.  Each        
  6887.      offset from the array is associated with the corresponding       
  6888.      name from the string table (in order).  The names in the         
  6889.      string table are all the defined global symbols found in the     
  6890.      common object files in the archive.  Each offset is the          
  6891.      location of the archive header for the associated symbol.        
  6892.                                                                       
  6893. SEE ALSO                                                              
  6894.      ar(1), ld(1), strip(1), ldahread(3X), ldfcn(4), a.out(4).        
  6895.                                                                       
  6896. CAVEATS                                                               
  6897.      strip removes all archive symbol entries from the header.        
  6898.      The archive symbol entries must be restored with the ts          
  6899.      option of ar command before the archive can be used with the
  6900.      link editor ld.
  6901.                                             INDEX
  6902.  
  6903.  
  6904. .netrc file..............................................................................93
  6905. .profile..................................................................................1
  6906. HOME variable.............................................................................1
  6907. Object programs..........................................................................10
  6908.