更新时间:2021-08-27 19:50:39
封面
Title Page
Copyright and Credits
Learning AWK Programming
Dedication
Packt Upsell
Why subscribe?
PacktPub.com
Contributors
About the author
About the reviewers
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Get in touch
Reviews
Getting Started with AWK Programming
AWK programming language overview
What is AWK?
Types of AWK
When and where to use AWK
Getting started with AWK
Installation on Linux
Using the package manager
Compiling from the source code
Workflow of AWK
Action and pattern structure of AWK
Example data file
Pattern-only statements
Action-only statements
Printing each input line/record
Using the BEGIN and END blocks construct
The BEGIN block
The body block
The END block
Patterns
Actions
Running AWK programs
AWK as a Unix command line
AWK as a filter (reading input from the Terminal)
Running AWK programs from the source file
AWK programs as executable script files
Extending the AWK command line on multiple lines
Comments in AWK
Shell quotes with AWK
Data files used as examples in this book
Some simple examples with default usage
Multiple rules with AWK
Using standard input with names in AWK
AWK standard options
Standard command-line options
The -F option – field separator
The -f option (read source file)
The -v option (assigning variables)
GAWK-only options
The --dump-variables option (AWK global variables)
The --profile option (profiling)
The --sandbox option
The -i option (including other files in your program)
Include other files in the GAWK program (using @include)
The -V option
Summary
Working with Regular Expressions
Introduction to regular expressions
What is a regular expression?
Why use regular expressions?
Using regular expressions with AWK
Regular expressions as string-matching patterns with AWK
Basic regular expression construct
Understanding regular expression metacharacters
Quoted metacharacter
Anchors
Matching at the beginning of a string
Matching at the end of a string
Dot
Brackets expressions
Character classes
Named character classes (POSIX standard)
Complemented bracket expressions
Complemented character classes
Complemented named character classes
Alternation operator
Unary operator for repetition
Closure
Positive closure
Zero or one
Repetition ranges with interval expressions
A single number in brackets
A single number followed by a comma in brackets
Two numbers in brackets
Grouping using parentheses
Concatenation using alternation operator within parentheses
Backreferencing in regular expressions – sed and grep
Precedence in regular expressions
GAWK-specific regular expression operators
Matching whitespaces