Classic Shell Scripting - Arnold Robbins [0]
Table of Contents
A Note Regarding Supplemental Files
Foreword
Preface
Intended Audience
What You Should Already Know
Chapter Summary
Conventions Used in This Book
Code Examples
Unix Tools for Windows Systems
Cygwin
DJGPP
MKS Toolkit
AT&T UWIN
Safari Enabled
We'd Like to Hear from You
Acknowledgments
1. Background
1.1. Unix History
1.2. Software Tools Principles
1.3. Summary
2. Getting Started
2.1. Scripting Languages Versus Compiled Languages
2.2. Why Use a Shell Script?
2.3. A Simple Script
2.4. Self-Contained Scripts: The #! First Line
2.5. Basic Shell Constructs
2.5.1. Commands and Arguments
2.5.2. Variables
2.5.3. Simple Output with echo
2.5.4. Fancier Output with printf
2.5.5. Basic I/O Redirection
2.5.6. Basic Command Searching
2.6. Accessing Shell Script Arguments
2.7. Simple Execution Tracing
2.8. Internationalization and Localization
2.9. Summary
3. Searching and Substitutions
3.1. Searching for Text
3.1.1. Simple grep
3.2. Regular Expressions
3.2.1. What Is a Regular Expression?
3.2.2. Basic Regular Expressions
3.2.3. Extended Regular Expressions
3.2.4. Regular Expression Extensions
3.2.5. Which Programs Use Which Regular Expressions?
3.2.6. Making Substitutions in Text Files
3.2.7. Basic Usage
3.2.8. sed Operation
3.2.9. Matching Specific Lines
3.2.10. How Much Text Gets Changed?
3.2.11. Lines Versus Strings
3.3. Working with Fields
3.3.1. Text File Conventions
3.3.2. Selecting Fields with cut
3.3.3. Joining Fields with join
3.3.4. Rearranging Fields with awk
3.4. Summary
4. Text Processing Tools
4.1. Sorting Text
4.1.1. Sorting by Lines
4.1.2. Sorting by Fields
4.1.3. Sorting Text Blocks
4.1.4. Sort Efficiency
4.1.5. Sort Stability
4.1.6. Sort Wrap-Up
4.2. Removing Duplicates
4.3. Reformatting Paragraphs
4.4. Counting Lines, Words, and Characters
4.5. Printing
4.5.1. Evolution of Printing Technology
4.5.2. Other Printing Software
4.6. Extracting the First and Last Lines
4.7. Summary
5. Pipelines Can Do Amazing Things
5.1. Extracting Data from Structured Text Files
5.2. Structured Data for the Web
5.3. Cheating at Word Puzzles
5.4. Word Lists
5.5. Tag Lists
5.6. Summary
6. Variables, Making Decisions, and Repeating Actions
6.1. Variables and Arithmetic
6.1.1. Variable Assignment and the Environment
6.1.2. Parameter Expansion
6.1.3. Arithmetic Expansion
6.2. Exit Statuses
6.2.1. Exit Status Values
6.2.2. if-elif-else-fi
6.2.3. Logical NOT, AND, and OR
6.2.4. The test Command
6.3. The case Statement
6.4. Looping
6.4.1. for Loops
6.4.2. while and until Loops
6.4.3. break and continue
6.4.4. shift and Option Processing
6.5. Functions
6.6. Summary
7. Input and Output, Files, and Command Evaluation
7.1. Standard Input, Output, and Error
7.2. Reading Lines with read
7.3. More About Redirections
7.3.1. Additional Redirection Operators
7.3.2. File Descriptor Manipulation
7.4. The Full Story on printf
7.5. Tilde Expansion and Wildcards
7.5.1. Tilde Expansion
7.5.2. Wildcarding
7.6. Command Substitution
7.6.1. Using sed for the head Command
7.6.2. Creating a Mailing List
7.6.3. Simple Math: expr
7.7. Quoting
7.8. Evaluation Order and eval
7.8.1. The eval Statement
7.8.2. Subshells and Code Blocks
7.9. Built-in Commands
7.9.1. The set Command
7.10. Summary
8. Production Scripts
8.1. Path Searching
8.2. Automating Software Builds
8.3. Summary
9. Enough awk to Be Dangerous
9.1. The awk Command Line
9.2. The awk Programming Model
9.3. Program Elements
9.3.1. Comments and Whitespace
9.3.2. Strings and String Expressions
9.3.3. Numbers and Numeric Expressions
9.3.4. Scalar Variables
9.3.5. Array Variables
9.3.6. Command-Line Arguments
9.3.7. Environment Variables
9.4. Records and Fields
9.4.1. Record Separators
9.4.2. Field Separators
9.4.3. Fields
9.5. Patterns and Actions
9.5.1. Patterns
9.5.2. Actions
9.6. One-Line Programs in awk
9.7. Statements
9.7.1. Sequential Execution
9.7.2. Conditional Execution