UNIX for Intermediate Users Developed by: User Liaison Section, D-7131 [Name and numbers removed at author's request] Revision Date: TABLE OF CONTENTS I. INTRODUCTION........................................................................ ii A. Audience..................................................................... ii B. Course Objectives............................................................ ii C. Course Handout Conventions...................................................iii 1. THE FILE CALLED .profile AND PROCESSES.............................................. 1 1.1 HOME........................................................................ 1 1.2 PATH........................................................................ 2 1.3 INGRES Environment Variables................................................ 2 1.4 ING_HOME.................................................................... 3 1.5 TERM_INGRES................................................................. 3 1.6 ING_EDIT.................................................................... 3 1.7 Processes................................................................... 4 1.8 Executing a Command......................................................... 4 1.9 Process Identification...................................................... 5 1.10 Interrupt Handling......................................................... 7 2. COMPILING "C" PROGRAMS............................................................... 10 2.1 "C": Sample Program with a Main and Two Functions in One ............................................................ 10 2.2 "C": Compiling a Program.................................................... 12 2.3 "C": Renaming the Executable Module......................................... 13 2.4 "C": Giving a Name to the Output File....................................... 14 2.5 "C": Producing an Assembly Listing.......................................... 15 2.6 "C": Main and Two Functions in Three Separate Source Files.............................................................. 16 2.7 "C": Compiling but Not Producing an Executable Module.................................................................... 17 3. COMPILING FORTRAN PROGRAMS......................................................... 18 3.1 FORTRAN: Sample Program a Main and Two Subroutines............................................................... 18 3.2 FORTRAN: Compiling a Program................................................ 19 3.3 FORTRAN: Renaming the Executable Module..................................... 20 3.4 FORTRAN: Giving a Name to the Output File................................... 21 3.5 FORTRAN: Producing an Assembly Listing...................................... 22 3.6 FORTRAN: Main and Two Subroutines in Three Separate Source Files........................................ 23 3.7 FORTRAN: Compiling But Not Producing an Executable Module.................................................................... 24 3.8 FORTRAN: Compiling Object Files to Produce an Executable Module....................................... 25 4. COMPILING COBOL PROGRAMS............................................................ 26 4.1 COBOL: Sample Program with a Main and Two Subroutines............................................................... 26 4.2 COBOL: Compiling a Program.................................................. 27 4.3 COBOL: Running a Program.................................................... 28 Workshop 2-4..................................................................... 30 5. UNIX TOOLS.......................................................................... 34 5.1 The make Utility............................................................ 34 p: A Pattern Matching Filter............................................................ 37 5.2.1 More on Regular Expressions........................................ 38 5.2.2 Closure............................................................ 42 5.2.3 Some Nice grep Options ................................ 43 5.2.4 Summary of Regular Expression Characters........................... 44 5.3 sed: Edit a File to Standard Output......................................... 45 5.4 awk: A Pattern Matching Programming Language................................ 49 5.5 sort: Sort a File........................................................... 53 5.6 Archiver and Library Maintainer............................................. 56 5.7 Creating an Archive File with Object Modules................................ 57 5.8 Verifying the Contents of the Archive File.................................. 57 5.9 Removing Duplicate Object Files............................................. 58 5.10 Compiling Main and Archive Files........................................... 58 Workshop 5....................................................................... 59 6. UNIX UTILITIES PART I - DISPLAY AND MANIPULATE FILES................................ 63 7. UNIX UTILITIES PART II - DISPLAY AND ALTER STAUTS................................... 73 8. UNIX UTILITIES PART III - MISCELLANEOUS............................................. 85 9. ADVANCED FEATURES OF FTP............................................................ 90 9.1 Initializing FTP on UMAX.................................................... 91 9.2 Multiple File Transfers..................................................... 92 9.3 Auto Login Feature.......................................................... 93 9.4 Macros...................................................................... 95 9.5 Filename Translation........................................................ 96 9.6 Aborting Transfers.......................................................... 97 9.7 More Remote Computer Commands............................................... 98 Workshop 10...................................................................... 99 APPENDIX A - sh.........................................................................101 APPENDIX B - ftp........................................................................116 APPENDIX C - C Compiler.................................................................128 APPENDIX D - FORTRAN Compiler...........................................................137 APPENDIX E - lint.......................................................................147 APPENDIX F - cb.........................................................................151 APPENDIX G - ar.........................................................................152 INDEX...................................................................................157 I. INTRODUCTION A. Audience This course is for individuals who need to use utilities and advanced features of the UNIX operating system. B. Course Objectives Upon successful completion of this course the student will be able to: 1. Compile C, FORTRAN, and COBOL programs. 2. Create processes to run in the background 3. Use advanced features of FTP such as: multiple file transfers, auto logins, macros, globbing, filename translation, aborting transfers, and other remote computer commands. 4. Use UNIX utility programs such as grep, sed, awk, sort, and others. 5. Use the make utility. 6. Understand processes, including structure, executing a command, process identification, exit status, plus . (dot) and exec processing. C. Course Handout Conventions There are several conventions used in this handout for consistency and easier interpretation: 1. Samples of actual terminal sessions are single-lined boxed. 2. User entries are shown in bold print and are underlined. exit 3. All keyboard functions in the text will be bold. (Ret) Backspace Tab Ctrl-F6 Print (Shift-F7) Go to DOS (1) NOTE: (Ret) indicates the Return or Enter key located above the right Shift key. 4. Examples of user entries not showing the computer's response are in dotted-lined boxes. 5. Command formats are double-lined boxed. 6. Three dots either in vertical or horizontal alignment mean continuation or that data is missing from diagram.