CONTENTS
- PREFACE
- CHAPTER 1: AN AWK TUTORIAL
- 1.1 Getting Started
- The Structure of an AWK Program
- Running an AWK Program
- Errors
- 1.2 Simple Output
- Printing Every Line
- Printing Certain Fields
- NF, the Number of Fields
- Computing and Printing
- Printing Line Numbers
- Putting Text in the Output
- 1 .3 Fancier Output
- Lining Up Fields
- Sorting the Output
- 1.4 Selection
- Selection by Comparison
- Selection by Computation
- Selection by Text Content
- Combinations of Patterns
- Data Validation
- BEGIN and END
- 1.5 Computing with AWK
- Counting
- Computing Sums and Averages
- Handling Text
- String Concatenation
- Printing the Last Input Line
- Built-in Functions
- Counting Lines, Words, and Characters
- 1.6 Control-Flow Statements
- If-Else Statement
- While Statement
- For Statement
- 1 .7 Arrays
- 1.8 A Handful of Useful “One-liners”
- 1.9 What Next?
- CHAPTER 2: THE AWK LANGUAGE
- The Input File
countries
- Program Format
- 2.1 Patterns
- BEGIN and END
- Expressions as Patterns
- String-Matching Patterns
- Regular Expressions
- Compound Patterns
- Range Patterns
- Summary of Patterns
- 2.2 Actions
- Expressions
- Control-Flow Statements
- Empty Statement
- Arrays
- 2.3 User-Defined Functions
- 2.4 Output
- The
print
Statement
- Output Separators
- The
printf
Statement
- Output into Files
- Output into Pipes
- Closing Files and Pipes
- 2.5 Input
- Input Separators
- Multiline Records
- The
getline
Function
- Command-Line Variable Assignments
- Command-Line Arguments
- 2.6 Interaction with Other Programs
- The
system
Function
- Making a Shell Command from an AWK Program
- 2.7 Summary
- CHAPTER 3: DATA PROCESSING
- 3.1 Data Transformation and Reduction
- Summing Columns
- Computing Percentages and Quantiles
- Numbers with Commas
- Fixed-Field Input
- Program Cross- Reference Checking
- Formatted Output
- 3.2 Data Validation
- Balanced Delimiters
- Password- File Checking
- Generating Data-Validation Programs
- Which Version of AWK?
- 3.3 Bundle and Unbundle
- 3.4 Multiline Records
- Records Separated by Blank Lines
- Processing Multiline Records
- Records with Headers and Trailers
- Name-Value Data
- 3.5 Summary
- CHAPTER 4: REPORTS AND DATABASES
- 4.1 Generating Reports
- A Simple Report
- A More Complex Report
- 4.2 Packaged Queries and Reports
- 4.3 A Relational Database System
- Natural Joins
- The relfile
- q, an awk-like query language
- qawk, a q-to-awk translator
- 4.4 Summary
- CHAPTER 5: PROCESSING WORDS
- 5.1 Random Text Generation
- Random Choices
- Cliche Generation
- Random Sentences
- 5.2 Interactive Text-Manipulation
- Skills Testing: Arithmetic
- Skills Testing: Quiz
- 5.3 Text Processing
- Word Counts
- Text Formatting
- Maintaining Cross-References in Manuscripts
- Making a KWIC Index
- Making Indexes
- 5.4 Summary
- CHAPTER 6: LITTLE LANGUAGES
- 6.1 An Assembler and Interpreter
- 6.2 A Language for Drawing Graphs
- 6.3 A Sort Generator
- 6.4 A Reverse-Polish Calculator
- 6.5 An Infix Calculator
- 6.6 Recursive-Descent Parsing
- 6.7 Summary
- CHAPTER 7: EXPERIMENTS WITH ALGORITHMS
- 7.1 Sorting
- Insertion Sort
- Quicksort
- Heapsort
- 7.2 Profiling
- 7.3 Topological Sorting
- Breadth-First Topological Sort
- Depth-First Search
- Depth-First Topological Sort
- 7.4 Make: A File Updating Program
- 7.5 Summary
- CHAPTER 8: EPILOG
- 8.1 AWK as a Language
- 8.2 Performance
- 8.3 Conclusion
- APPENDIX A: AWK SUMMARY
- APPENDIX B: ANSWERS TO SELECTED EXERCISES
- INDEX