Book description
sed & awk describes two text processing programs that are mainstays of the UNIX programmer's toolbox.sed is a "stream editor" for editing streams of text that might be too large to edit as a single file, or that might be generated on the fly as part of a larger data processing step. The most common operation done with sed is substitution, replacing one block of text with another.awk is a complete programming language. Unlike many conventional languages, awk is "data driven" -- you specify what kind of data you are interested in and the operations to be performed when that data is found. awk does many things for you, including automatically opening and closing data files, reading records, breaking the records up into fields, and counting the records. While awk provides the features of most conventional programming languages, it also includes some unconventional features, such as extended regular expression matching and associative arrays. sed & awk describes both programs in detail and includes a chapter of example sed and awk scripts.This edition covers features of sed and awk that are mandated by the POSIX standard. This most notably affects awk, where POSIX standardized a new variable, CONVFMT, and new functions, toupper() and tolower(). The CONVFMT variable specifies the conversion format to use when converting numbers to strings (awk used to use OFMT for this purpose). The toupper() and tolower() functions each take a (presumably mixed case) string argument and return a new version of the string with all letters translated to the corresponding case.In addition, this edition covers GNU sed, newly available since the first edition. It also updates the first edition coverage of Bell Labs nawk and GNU awk (gawk), covers mawk, an additional freely available implementation of awk, and briefly discusses three commercial versions of awk, MKS awk, Thompson Automation awk (tawk), and Videosoft (VSAwk).
Publisher resources
Table of contents
- A Note Regarding Supplemental Files
- Dedication
- Preface
- 1. Power Tools for Editing
- 2. Understanding Basic Operations
-
3. Understanding Regular Expression Syntax
- 3.1. That’s an Expression
-
3.2. A Line-Up of Characters
- 3.2.1. The Ubiquitous Backslash
- 3.2.2. A Wildcard
- 3.2.3. Writing Regular Expressions
- 3.2.4. Character Classes
- 3.2.5. Repeated Occurrences of a Character
- 3.2.6. What’s the Word? Part I
- 3.2.7. Positional Metacharacters
- 3.2.8. A Span of Characters
- 3.2.9. Alternative Operations
- 3.2.10. Grouping Operations
- 3.2.11. What’s the Word? Part II
- 3.2.12. Your Replacement Is Here
- 3.2.13. Limiting the Extent
- 3.3. I Never Metacharacter I Didn’t Like
- 4. Writing sed Scripts
- 5. Basic sed Commands
- 6. Advanced sed Commands
- 7. Writing Scripts for awk
- 8. Conditionals, Loops, and Arrays
- 9. Functions
- 10. The Bottom Drawer
-
11. A Flock of awks
-
11.1. Original awk
- 11.1.1. Escape Sequences
- 11.1.2. Exponentiation
- 11.1.3. The C Conditional Expression
- 11.1.4. Variables as Boolean Patterns
- 11.1.5. Faking Dynamic Regular Expressions
- 11.1.6. Control Flow
- 11.1.7. Field Separating
- 11.1.8. Arrays
- 11.1.9. The getline Function
- 11.1.10. Functions
- 11.1.11. Built-In Variables
-
11.2. Freely Available awks
- 11.2.1. Common Extensions
- 11.2.2. Bell Labs awk
-
11.2.3. GNU awk (gawk)
- 11.2.3.1. Command line options
- 11.2.3.2. An awk program search path
- 11.2.3.3. Line continuation
- 11.2.3.4. Extended regular expressions
- 11.2.3.5. Regular expression record terminators
- 11.2.3.6. Separating fields
- 11.2.3.7. Additional special files
- 11.2.3.8. Additional variables
- 11.2.3.9. Additional functions
- 11.2.3.10. A general substitution function
- 11.2.3.11. Time management for programmers
- 11.2.4. Michael’s awk (mawk)
- 11.3. Commercial awks
- 11.4. Epilogue
-
11.1. Original awk
- 12. Full-Featured Applications
-
13. A Miscellany of Scripts
- 13.1. uutot.awk—Report UUCP Statistics
- 13.2. phonebill—Track Phone Usage
- 13.3. combine—Extract Multipart uuencoded Binaries
- 13.4. mailavg—Check Size of Mailboxes
- 13.5. adj—Adjust Lines for Text Files
- 13.6. readsource—Format Program Source Files for troff
- 13.7. gent—Get a termcap Entry
- 13.8. plpr—lpr Preprocessor
- 13.9. transpose—Perform a Matrix Transposition
- 13.10. m1—Simple Macro Processor
- A. Quick Reference for sed
- B. Quick Reference for awk
- C. Supplement for Chapter 12
- Index
- About the Authors
- Colophon
- Copyright
Product information
- Title: sed & awk, 2nd Edition
- Author(s):
- Release date: March 1997
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781565922259
You might also like
book
The AWK Programming Language, 2nd Edition
Awk was developed in 1977 at Bell Labs, and it’s still a remarkably useful tool for …
video
Bash Shell Scripting, 2nd Edition
8 Hours of Video Instruction Overview Bash is the best way for you to efficiently and …
book
The Linux Command Line, 2nd Edition
The Linux Command Line takes you from your very first terminal keystrokes to writing full programs …
video
Linux Fundamentals, 2nd Edition
10+ Hours of Video Instruction More than 10 hours of video instruction to get you up …