Shell Scripting Primer
PDF
Companion Files
Introduction
Shell Script Basics
Shell Script Dialects
She Sells C Shells
Tips for Shell Users
Shell Variables and Printing
Exporting Shell Variables
Shell Script Input and Output Using printf and read
Bulk I/O Using the cat Command
Pipes and Redirection
Basic Control Statements
Variables, Expansion, and Quoting
Result Codes, Subroutines, Scoping, and Sourcing
Working With Result Codes
Basic Subroutines
Anonymous Subroutines
Variable Scoping
Including One Shell Script Inside Another
Background Jobs and Job Control
Paint by Numbers
The expr Command Also Does Math
The Easy Way: Parentheses
Other Comparisons
Beyond Basic Math
Regular Expressions Unfettered
Regular Expression Syntax
Positional Anchors and Flags
Wildcards and Repetition Operators
Character Classes and Groups
Quoting Special Characters
Capture Operators and Variables
Mixing Capture and Grouping Operators
Perl and Python Extensions
How awk-ward
A Simple awk Script
Conditional Filter Rules in awk
Changing the Record and Field Separators in awk
Skipping Records and Files
Control Statements in awk
Functions in awk
Working with Arrays in awk
File Input and Output
Designing Scripts for Cross-Platform Deployment
Bourne Shell Version
Managing Users and Groups
Working with Device I/O
Disk Management and Partitioning
File System Hierarchy
General Command-Line Tool Differences
Advanced Techniques
Data Structures, Arrays, and Indirection
Nonblocking I/O
Timing Loops
Trapping Signals
Special Shell Variables
Shell Text Formatting
Performance Tuning
Avoiding Unnecessary External Commands
Other Performance Tips
Appendix A: Other Tools and Information
General Tools
Text Processing Tools
File Commands
Disk Commands
Archiving and Compression Commands
For More Information
Appendix B: An Extreme Example: The Monte Carlo (Bourne) Method for Pi
Obtaining Random Numbers
Finding The Ordinal Rank of a Character
Complete Code Sample
Revision History