Advanced Bash-Scripting Guide An in-depth exploration of the art of shell scripting [6.6 ed.]
323
86
2MB
English
Pages [907]
Year 2012
Report DMCA / Copyright
DOWNLOAD PDF FILE
Table of contents :
Table of Contents
Chapter 1. Shell Programming!
Chapter 2. Starting Off With a Sha-Bang
2.1. Invoking the script
2.2. Preliminary Exercises
Part 2. Basics
Chapter 3. Special Characters
Chapter 4. Introduction to Variables and Parameters
4.1. Variable Substitution
4.2. Variable Assignment
4.3. Bash Variables Are Untyped
4.4. Special Variable Types
Chapter 5. Quoting
5.1. Quoting Variables
5.2. Escaping
Chapter 6. Exit and Exit Status
Chapter 7. Tests
7.1. Test Constructs
7.2. File test operators
7.3. Other Comparison Operators
7.4. Nested if/then Condition Tests
7.5. Testing Your Knowledge of Tests
Chapter 8. Operations and Related Topics
8.1. Operators
8.2. Numerical Constants
8.3. The Double-Parentheses Construct
8.4. Operator Precedence
Part 3. Beyond the Basics
Chapter 9. Another Look at Variables
9.1. Internal Variables
9.2. Typing variables: declare or typeset
9.2.1. Another use for declare
9.3. $RANDOM: generate random integer
Chapter 10. Manipulating Variables
10.1. Manipulating Strings
10.1.1. Manipulating strings using awk
10.1.2. Further Reference
10.2. Parameter Substitution
Chapter 11. Loops and Branches
11.1. Loops
11.2. Nested Loops
11.3. Loop Control
11.4. Testing and Branching
Chapter 12. Command Substitution
Chapter 13. Arithmetic Expansion
Chapter 14. Recess Time
Part 4. Commands
Chapter 15. Internal Commands and Builtins
15.1. Job Control Commands
Chapter 16. External Filters, Programs and Commands
16.1. Basic Commands
16.2. Complex Commands
16.3. Time / Date Commands
16.4. Text Processing Commands
16.5. File and Archiving Commands
16.6. Communications Commands
16.7. Terminal Control Commands
16.8. Math Commands
16.9. Miscellaneous Commands
Chapter 17. System and Administrative Commands
17.1. Analyzing a System Script
Part 5. Advanced Topics
Chapter 18. Regular Expressions
18.1. A Brief Introduction to Regular Expressions
18.2. Globbing
Chapter 19. Here Documents
19.1. Here Strings
Chapter 20. I/O Redirection
20.1. Using exec
20.2. Redirecting Code Blocks
20.3. Applications
Chapter 21. Subshells
Chapter 22. Restricted Shells
Chapter 23. Process Substitution
Chapter 24. Functions
24.1. Complex Functions and Function Complexities
24.2. Local Variables
24.2.1. Local variables and recursion.
24.3. Recursion Without Local Variables
Chapter 25. Aliases
Chapter 26. List Constructs
Chapter 27. Arrays
Chapter 28. Indirect References
Chapter 29. /dev and /proc
29.1. /dev
29.2. /proc
Chapter 30. Network Programming
Chapter 31. Of Zeros and Nulls
Chapter 32. Debugging
Chapter 33. Options
Chapter 34. Gotchas
Chapter 35. Scripting With Style
35.1. Unofficial Shell Scripting Stylesheet
Chapter 36. Miscellany
36.1. Interactive and non-interactive shells and scripts
36.2. Shell Wrappers
36.3. Tests and Comparisons: Alternatives
36.4. Recursion: a script calling itself
36.5. "Colorizing" Scripts
36.6. Optimizations
36.7. Assorted Tips
36.7.1. Ideas for more powerful scripts
36.7.2. Widgets
36.8. Security Issues
36.8.1. Infected Shell Scripts
36.8.2. Hiding Shell Script Source
36.8.3. Writing Secure Shell Scripts
36.9. Portability Issues
36.9.1. A Test Suite
36.10. Shell Scripting Under Windows
Chapter 37. Bash, versions 2, 3, and 4
37.1. Bash, version 2
37.2. Bash, version 3
37.2.1. Bash, version 3.1
37.2.2. Bash, version 3.2
37.3. Bash, version 4
37.3.1. Bash, version 4.1
37.3.2. Bash, version 4.2
Chapter 38. Endnotes
38.1. Author's Note
38.2. About the Author
38.3. Where to Go For Help
38.4. Tools Used to Produce This Book
38.4.1. Hardware
38.4.2. Software and Printware
38.5. Credits
38.6. Disclaimer
Bibliography
Appendix A. Contributed Scripts
Appendix B. Reference Cards
Appendix C. A Sed and Awk Micro-Primer
C.1. Sed
C.2. Awk
Appendix D. Parsing and Managing Pathnames
Appendix E. Exit Codes With Special Meanings
Appendix F. A Detailed Introduction to I/O and I/O Redirection
Appendix G. Command-Line Options
G.1. Standard Command-Line Options
G.2. Bash Command-Line Options
Appendix H. Important Files
Appendix I. Important System Directories
Appendix J. An Introduction to Programmable Completion
Appendix K. Localization
Appendix L. History Commands
Appendix M. Sample .bashrc and .bash_profile Files
Appendix N. Converting DOS Batch Files to Shell Scripts
Appendix O. Exercises
O.1. Analyzing Scripts
O.2. Writing Scripts
Appendix P. Revision History
Appendix Q. Download and Mirror Sites
Appendix R. To Do List
Appendix S. Copyright
Appendix T. ASCII Table
Index
Notes