Advanced Bash-Scripting Guide

Advanced Bash-Scripting Guide

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......................................................................................................................................................50 Chapter 4. Introduction to Variables and Parameters..................................................................................51 4.1. Variable Substitution.................................................................................................................................53 Notes......................................................................................................................................................55 4.2. Variable Assignment..................................................................................................................................57 4.3. Bash Variables Are Untyped.....................................................................................................................59 4.4. Special Variable Types..............................................................................................................................61 Notes......................................................................................................................................................65 Chapter 5. Quoting...........................................................................................................................................67 5.1. Quoting Variables......................................................................................................................................69 Notes......................................................................................................................................................70 5.2. Escaping......................................................................................................................................................73 Chapter 6. Exit and Exit Status.......................................................................................................................79 Notes......................................................................................................................................................81 Chapter 7. Tests................................................................................................................................................83 i Advanced Bash-Scripting Guide Table of Contents 7.1. Test Constructs...........................................................................................................................................85 Notes......................................................................................................................................................92 7.2. File test operators.......................................................................................................................................93 Notes......................................................................................................................................................95 7.3. Other Comparison Operators...................................................................................................................97 Notes....................................................................................................................................................102 7.4. Nested if/then Condition Tests................................................................................................................103 7.5. Testing Your Knowledge of Tests...........................................................................................................105 Chapter 8. Operations and Related Topics..................................................................................................107 8.1. Operators..................................................................................................................................................109 Notes....................................................................................................................................................115 8.2. Numerical Constants...............................................................................................................................117 8.3. The Double-Parentheses Construct........................................................................................................119 8.4. Operator Precedence...............................................................................................................................121 Notes....................................................................................................................................................123 Part 3. Beyond the Basics...............................................................................................................................125 Chapter 9. Another Look at Variables.........................................................................................................127 9.1. Internal Variables....................................................................................................................................129 Notes....................................................................................................................................................147 9.2. Typing variables: declare or typeset......................................................................................................149 9.2.1. Another use for declare..............................................................................................................151 Notes..............................................................................................................................................151 9.3. $RANDOM: generate random integer...................................................................................................153 Notes....................................................................................................................................................163 Chapter 10. Manipulating Variables.............................................................................................................165 10.1. Manipulating Strings.............................................................................................................................167 10.1.1. Manipulating strings using awk...............................................................................................174 10.1.2. Further Reference.....................................................................................................................175 Notes..............................................................................................................................................175 ii Advanced Bash-Scripting Guide Table of Contents 10.2. Parameter Substitution.........................................................................................................................177 Notes....................................................................................................................................................186 Chapter 11. Loops and Branches..................................................................................................................187 11.1. Loops.......................................................................................................................................................189 Notes....................................................................................................................................................202

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    978 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us