12.07.2015 Views

Advanced Bash-Scripting Guide

Advanced Bash-Scripting Guide

Advanced Bash-Scripting Guide

SHOW MORE
SHOW LESS
  • 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</strong>-<strong>Scripting</strong> <strong>Guide</strong>Table of ContentsChapter 1. Why Shell Programming?...............................................................................................................1Chapter 2. Starting Off With a Sha-Bang........................................................................................................32.1. Invoking the script............................................................................................................................62.2. Preliminary Exercises.......................................................................................................................6Part 2. Basics.......................................................................................................................................................7Chapter 3. Special Characters...........................................................................................................................8Chapter 4. Introduction to Variables and Parameters..................................................................................274.1. Variable Substitution......................................................................................................................274.2. Variable Assignment.......................................................................................................................304.3. <strong>Bash</strong> Variables Are Untyped..........................................................................................................314.4. Special Variable Types...................................................................................................................32Chapter 5. Quoting...........................................................................................................................................375.1. Quoting Variables...........................................................................................................................375.2. Escaping..........................................................................................................................................39Chapter 6. Exit and Exit Status.......................................................................................................................44Chapter 7. Tests................................................................................................................................................467.1. Test Constructs...............................................................................................................................467.2. File test operators............................................................................................................................527.3. Other Comparison Operators..........................................................................................................557.4. Nested if/then Condition Tests.......................................................................................................607.5. Testing Your Knowledge of Tests..................................................................................................60Chapter 8. Operations and Related Topics....................................................................................................628.1. Operators.........................................................................................................................................628.2. Numerical Constants.......................................................................................................................68Part 3. Beyond the Basics.................................................................................................................................70Chapter 9. Variables Revisited........................................................................................................................719.1. Internal Variables............................................................................................................................719.2. Manipulating Strings.......................................................................................................................889.2.1. Manipulating strings using awk............................................................................................959.2.2. Further Discussion.................................................................................................................969.3. Parameter Substitution....................................................................................................................969.4. Typing variables: declare or typeset.............................................................................................1059.5. Indirect References.......................................................................................................................1079.6. $RANDOM: generate random integer..........................................................................................1109.7. The Double Parentheses Construct...............................................................................................121i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!