Table of Contents
Chapter 1. Why Shell Programming?...............................................................................................................1
Chapter 2. Starting Off With a Sha-Bang........................................................................................................3
2.1. Invoking the script............................................................................................................................6
2.2. Preliminary Exercises.......................................................................................................................6
Part 2. Basics.......................................................................................................................................................7
Chapter 3. Special Characters...........................................................................................................................8
Chapter 4. Introduction to Variables and Parameters..................................................................................28
4.1. Variable Substitution......................................................................................................................28
4.2. Variable Assignment.......................................................................................................................31
4.3. Bash Variables Are Untyped..........................................................................................................32
4.4. Special Variable Types...................................................................................................................33
Chapter 5. Quoting...........................................................................................................................................39
5.1. Quoting Variables...........................................................................................................................39
5.2. Escaping..........................................................................................................................................41
Chapter 6. Exit and Exit Status.......................................................................................................................47
Chapter 7. Tests................................................................................................................................................49
7.1. Test Constructs...............................................................................................................................49
7.2. File test operators............................................................................................................................56
7.3. Other Comparison Operators..........................................................................................................59
7.4. Nested if/then Condition Tests.......................................................................................................64
7.5. Testing Your Knowledge of Tests..................................................................................................65
Chapter 8. Operations and Related Topics....................................................................................................66
8.1. Operators.........................................................................................................................................66
8.2. Numerical Constants.......................................................................................................................72
Part 3. Beyond the Basics.................................................................................................................................74
Chapter 9. Variables Revisited........................................................................................................................75
9.1. Internal Variables............................................................................................................................75
9.2. Manipulating Strings.......................................................................................................................92
9.2.1. Manipulating strings using awk..........................................................................................100
9.2.2. Further Reference................................................................................................................100
9.3. Parameter Substitution..................................................................................................................101
9.4. Typing variables: declare or typeset.............................................................................................110
9.4.1. Another use for declare.......................................................................................................112
9.5. Indirect References.......................................................................................................................112
9.6. $RANDOM: generate random integer..........................................................................................116
9.7. The Double-Parentheses Construct...............................................................................................127
Advanced Bash-Scripting Guide
i
Leave a Comment