UNIX Bourne Shell Programming

时间:2011-05-15 05:51:26
【文件属性】:

文件名称:UNIX Bourne Shell Programming

文件大小:318KB

文件格式:DOC

更新时间:2011-05-15 05:51:26

UNIX Bourne Shell Programming

I. INTRODUCTION.............................................. v
A. Audience............................................. v
B. Course Objectives.................................... v
C. Course Handout Conventions........................... vi

1. BOURNESHELL OVERVIEW...................................... 1
1.1 What is the BourneShell?............................ 2
1.2 Making a Bourne Shell Script Executable............. 3
1.3 Tracing Mechanisms.................................. 6
Workshop 1............................................... 9

2. USER, SHELL, AND READ-ONLY SHELL VARIABLES................ 11
2.1 User Variables...................................... 11
2.2 Shell Variables..................................... 14
2.2.1 HOME......................................... 14
2.2.2 IFS.......................................... 15
2.2.3 MAIL......................................... 15
2.2.4 MAILPATH..................................... 15
2.2.5 MAILCHECK.................................... 16
2.2.6 PATH......................................... 16
2.2.7 PS1.......................................... 17
2.2.8 PS2.......................................... 17
2.3 Read-Only User Variables............................ 18
2.4 Read-Only Shell Variables........................... 19
2.4.1 Name of the Calling Program.................. 19
2.4.2 Arguments.................................... 19
2.4.3 Shift........................................ 21
2.4.4 Set.......................................... 22
2.4.5 expr......................................... 23
Workshop 2............................................... 27

3. POSITIONAL PARAMETERS..................................... 33
3.1 Reading Input Into a Shell Variable................. 34
3.2 Command Substitution................................ 36
3.3 Comments in BourneShell Scripts..................... 38
3.4 BourneShell Environment - Exporting Variables....... 39
Workshop 3............................................... 41

4. CONTROL CONSTRUCTS:....................................... 45
4.1 Types of Tests Used with Control Constructs:........ 46
4.2 Test on Numeric Values.............................. 47
4.3 Test on Character Strings........................... 47
4.4 Test on File Types.................................. 49
4.5 if then............................................. 50
4.6 if then else........................................ 52
4.7 if then elif........................................ 54
4.8 for................................................. 55
4.9 while............................................... 57
4.10 until.............................................. 58
4.11 case............................................... 60
Workshop 4............................................... 63

5. COMPILING PROGRAMS IN UNIX................................. 67
5.1 "C": Sample Program with a Main and Two Functions
in One ................................. 67
5.2 "C": Compiling a Program............................ 69
5.3 "C": Renaming the Executable Module................. 71
5.4 "C": Giving a Name to the Output File............... 72
5.5 "C": Producing an Assembly Listing.................. 73
5.6 "C": Main and Two Functions in Three Separate Source
Files.......................................... 74
5.7 "C": Compiling but Not Producing an Executable
Module............................................. 75
5.8 FORTRAN: Sample Program a Main and Two Subroutine... 76
5.9 FORTRAN: Compiling a Program........................ 77
5.10 FORTRAN: Renaming the Executable Module............ 79
5.11 FORTRAN: Giving a Name to the Output File.......... 80
5.12 FORTRAN: Producing an Assembly Listing............. 81
5.13 FORTRAN: Main and Two Subroutines in Three Separate
Source Files.............................. 82
5.14 FORTRAN: Compiling But Not Producing an Executable
Module.................................... 83
5.15 FORTRAN: Compiling Object Files to Produce an
Executable Module............................. 84
5.16 COBOL: Sample Program with a Main and Two
Subroutines................................. 85
5.17 COBOL: Compiling a Program......................... 86
5.18 COBOL: Running a Program........................... 87
Workshop 5............................................... 89

6. UNIX TOOLS................................................ 95
6.1 Processes........................................... 95
6.2 Executing a Command................................. 95
6.3 Process Identification.............................. 95
6.4 grep: A Pattern Matching Filter..................... 98
6.4.1 More on Regular Expressions.................. 99
6.4.2 Closure......................................103
6.4.3 Some Nice grep Options ......................104
6.4.4 Summary of Regular Expression Characters.....105
6.5 sed: Edit a File to Standard Output.................106
6.6 awk: A Pattern Matching Programming Language........110
6.7 sort: Sort a File...................................114
6.8 What Other Useful UNIX Tools are Available..........117
6.9 Archiver and Library Maintainer.....................118
6.9.1 ar: Creating an Archive File with Object
Modules.....................................119
6.9.2 ar: Verifying the Contents of the Archive
File.......................................119
6.9.3 ar: Removing Duplicate Object Files..........120
6.9.4 ar: Compiling Main and Archive Files.........120
Workshop 6...............................................121


7. VAX DCL TO UNIX SHELL SCRIPT CONVERSION...................125
7.1 Processes...........................................127
7.2 Pipes...............................................128
7.3 Input, Output, and Error Redirection................129
7.4 Command Structure and File Naming Conventions.......131
7.5 File Management Commands............................133
7.6 Metacharacters......................................135
7.7 Wildcards: Are They Really Wild?....................136
7.8 Summary.............................................137
Workshop 7...............................................139

8. ADVANCED FEATURES OF FTP..................................143
8.1 Initializing FTP on UMAX............................144
8.2 Multiple File Transfers.............................145
8.3 Auto Login Feature..................................146
8.4 Macros..............................................148
8.5 Filename Translation................................149
8.6 Aborting Transfers..................................150
8.7 More Remote Computer Commands.......................151
Workshop 8...............................................153

9. OPTIONAL CHAPTER - KORNSHELL PROGRAMMING..................155
9.1 KornShell Variables.................................155
9.2 User Defined Variables..............................157
9.3 Values of Variables Between Child and Parent
Processes...........................................158
9.4 ksh: Aliases........................................159
9.5 ksh: Command Line Editing...........................161
9.6 ksh: Interactive Command Line Editing...............162
9.7 ksh: Functions......................................164
9.8 ksh: The Select Construct...........................166
9.9 ksh: Tracing and Conditional Execution..............168
Workshop 9...............................................169

APPENDIX A - sh...............................................173

APPENDIX B - test.............................................189

APPENDIX C - expr.............................................193


















INDEX.........................................................279



网友评论