Advanced Bash−Scripting Guide
Advanced Bash-Scripting Guide - Nicku.org
Advanced Bash-Scripting Guide - Nicku.org
- No tags were found...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Advanced</strong> <strong>Bash−Scripting</strong> <strong>Guide</strong><br />
Table of Contents<br />
Chapter 1. Why Shell Programming?...............................................................................................................1<br />
Chapter 2. Starting Off With a Sha−Bang.......................................................................................................3<br />
2.1. Invoking the script............................................................................................................................5<br />
2.2. Preliminary Exercises.......................................................................................................................5<br />
Part 2. Basics.......................................................................................................................................................6<br />
Chapter 3. Special Characters...........................................................................................................................7<br />
Chapter 4. Introduction to Variables and Parameters..................................................................................23<br />
4.1. Variable Substitution......................................................................................................................23<br />
4.2. Variable Assignment.......................................................................................................................25<br />
4.3. Bash Variables Are Untyped..........................................................................................................26<br />
4.4. Special Variable Types...................................................................................................................28<br />
Chapter 5. Quoting...........................................................................................................................................32<br />
Chapter 6. Exit and Exit Status.......................................................................................................................38<br />
Chapter 7. Tests................................................................................................................................................40<br />
7.1. Test Constructs...............................................................................................................................40<br />
7.2. File test operators............................................................................................................................46<br />
7.3. Comparison operators (binary).......................................................................................................49<br />
7.4. Nested if/then Condition Tests.......................................................................................................54<br />
7.5. Testing Your Knowledge of Tests..................................................................................................54<br />
Chapter 8. Operations and Related Topics....................................................................................................55<br />
8.1. Operators.........................................................................................................................................55<br />
8.2. Numerical Constants.......................................................................................................................61<br />
Part 3. Beyond the Basics.................................................................................................................................63<br />
Chapter 9. Variables Revisited........................................................................................................................64<br />
9.1. Internal Variables............................................................................................................................64<br />
9.2. Manipulating Strings.......................................................................................................................79<br />
9.2.1. Manipulating strings using awk............................................................................................83<br />
9.2.2. Further Discussion.................................................................................................................84<br />
9.3. Parameter Substitution....................................................................................................................84<br />
9.4. Typing variables: declare or typeset...............................................................................................92<br />
9.5. Indirect References to Variables.....................................................................................................94<br />
9.6. $RANDOM: generate random integer............................................................................................96<br />
9.7. The Double Parentheses Construct...............................................................................................101<br />
Chapter 10. Loops and Branches..................................................................................................................103<br />
10.1. Loops..........................................................................................................................................103<br />
10.2. Nested Loops..............................................................................................................................113<br />
10.3. Loop Control...............................................................................................................................114<br />
i