
Advanced Bash-Scripting Guide Advanced Bash-Scripting Guide Table of Contents Advanced Bash-Scripting Guide.......................................................................................................................1 An in-depth exploration of the art of shell scripting................................................................................1 Mendel Cooper..................................................................................................................................1 Dedication............................................................................................................................................................3 Part 1. Introduction..........................................................................................................................................15 Chapter 1. Shell Programming!.......................................................................................................................17 Notes......................................................................................................................................................18 Chapter 2. Starting Off With a Sha-Bang......................................................................................................21 2.1. Invoking the script.....................................................................................................................................25 Notes......................................................................................................................................................25 2.2. Preliminary Exercises................................................................................................................................27 Part 2. Basics.....................................................................................................................................................29 Chapter 3. Special Characters.........................................................................................................................31 Notes......................................................................................................................................................51 Chapter 4. Introduction to Variables and Parameters..................................................................................53 4.1. Variable Substitution.................................................................................................................................55 Notes......................................................................................................................................................57 4.2. Variable Assignment..................................................................................................................................59 4.3. Bash Variables Are Untyped.....................................................................................................................61 4.4. Special Variable Types..............................................................................................................................63 Notes......................................................................................................................................................67 Chapter 5. Quoting...........................................................................................................................................69 5.1. Quoting Variables......................................................................................................................................71 Notes......................................................................................................................................................73 5.2. Escaping......................................................................................................................................................75 Chapter 6. Exit and Exit Status.......................................................................................................................83 Notes......................................................................................................................................................85 Chapter 7. Tests................................................................................................................................................87 i Advanced Bash-Scripting Guide Table of Contents 7.1. Test Constructs...........................................................................................................................................89 Notes......................................................................................................................................................96 7.2. File test operators.......................................................................................................................................97 Notes....................................................................................................................................................100 7.3. Other Comparison Operators.................................................................................................................101 Notes....................................................................................................................................................106 7.4. Nested if/then Condition Tests................................................................................................................107 7.5. Testing Your Knowledge of Tests...........................................................................................................109 Chapter 8. Operations and Related Topics..................................................................................................111 8.1. Operators..................................................................................................................................................113 Notes....................................................................................................................................................119 8.2. Numerical Constants...............................................................................................................................121 8.3. The Double-Parentheses Construct........................................................................................................123 8.4. Operator Precedence...............................................................................................................................125 Notes....................................................................................................................................................127 Part 3. Beyond the Basics...............................................................................................................................129 Chapter 9. Another Look at Variables.........................................................................................................131 9.1. Internal Variables....................................................................................................................................133 Notes....................................................................................................................................................151 9.2. Typing variables: declare or typeset......................................................................................................153 9.2.1. Another use for declare..............................................................................................................155 Notes..............................................................................................................................................155 9.3. $RANDOM: generate random integer...................................................................................................157 Notes....................................................................................................................................................168 Chapter 10. Manipulating Variables.............................................................................................................169 10.1. Manipulating Strings.............................................................................................................................171 10.1.1. Manipulating strings using awk...............................................................................................178 10.1.2. Further Reference.....................................................................................................................179 Notes..............................................................................................................................................179 ii Advanced Bash-Scripting Guide Table of Contents 10.2. Parameter Substitution.........................................................................................................................181 Notes....................................................................................................................................................190 Chapter 11. Loops and Branches..................................................................................................................191 11.1. Loops.......................................................................................................................................................193 Notes....................................................................................................................................................207
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages1036 Page
-
File Size-