Book description
Text processing and pattern matching simplified
About This Book
- Master the fastest and most elegant big data munging language
- Implement text processing and pattern matching using the advanced features of AWK and GAWK
- Implement debugging and inter-process communication using GAWK
Who This Book Is For
This book is for developers or analysts who are inclined to learn how to do text processing and data extraction in a Unix-like environment. Basic understanding of Linux operating system and shell scripting will help you to get the most out of the book.
What You Will Learn
- Create and use different expressions and control flow statements in AWK
- Use Regular Expressions with AWK for effective text-processing
- Use built-in and user-defined variables to write AWK programs
- Use redirections in AWK programs and create structured reports
- Handle non-decimal input, 2-way inter-process communication with Gawk
- Create small scripts to reformat data to match patterns and process texts
In Detail
AWK is one of the most primitive and powerful utilities which exists in all Unix and Unix-like distributions. It is used as a command-line utility when performing a basic text-processing operation, and as programming language when dealing with complex text-processing and mining tasks. With this book, you will have the required expertise to practice advanced AWK programming in real-life examples.
The book starts off with an introduction to AWK essentials. You will then be introduced to regular expressions, AWK variables and constants, arrays and AWK functions and more. The book then delves deeper into more complex tasks, such as printing formatted output in AWK, control flow statements, GNU's implementation of AWK covering the advanced features of GNU AWK, such as network communication, debugging, and inter-process communication in the GAWK programming language which is not easily possible with AWK.
By the end of this book, the reader will have worked on the practical implementation of text processing and pattern matching using AWK to perform routine tasks.
Style and approach
An easy-to-follow, step by step guide which will help you get to grips with real-world applications of AWK programming.
Table of contents
- Title Page
- Copyright and Credits
- Dedication
- Packt Upsell
- Contributors
- Preface
-
Getting Started with AWK Programming
- AWK programming language overview
- Getting started with AWK
- AWK standard options
- Summary
-
Working with Regular Expressions
- Introduction to regular expressions
- Basic regular expression construct
- Understanding regular expression metacharacters
- Precedence in regular expressions
- GAWK-specific regular expression operators
- Case-sensitive matching
- Escape sequences
- Summary
- AWK Variables and Constants
- Working with Arrays in AWK
-
Printing Output in AWK
- The print statement
- Role of output separator in print statement
- Pretty printing with the printf statement
- Escape sequences for special character printing
- Different format control characters in the format specifier
-
Format specification modifiers
- Printing with fixed column width
- Using the minus modifier (-) for left justification
- Printing with fixed width â right justified
- Using hash modifier (#)
- Using plus modifier (+) for prefixing with sign/symbol
- Printing with prefix sign/symbol
- Dot precision as modifier
- Positional modifier using integer constant followed by $ (N$):
- Redirecting output to file
- Summary
-
AWK Expressions
- AWK variables and constants
- Arithmetic expressions using binary operators
- Assignment expressions
- Increment and decrement expressions
- Relational expressions
- Logical or Boolean expressions
- Ternary expressions
- Unary expressions
- Exponential expressions
- String concatenation
- Regular expression operators
- Operators' Precedence
- Summary
- AWK Control Flow Statements
-
AWK Functions
-
Built-in functions
- Arithmetic functions
-
String functions
- The index (str, sub) function
- The length ( string ) function
- The split (str, arr, regex) function
- The substr (str, start, [ length ]) function
- The sub (regex, replacement, string) function
- The gsub (regex, replacement, string) function
- The gensub (regex, replacement, occurrence, [ string ]) function
- The match (string, regex) function
- The tolower (string) function
- The toupper (string) function
- The sprintf (format, expression) function
- The strtonum (string) function
- Input/output functions
- The time function
- Bit-manipulating functions
- User-defined functions
- Summary
-
Built-in functions
- GNU's Implementation of AWK â GAWK (GNU AWK)
-
Practical Implementation of AWK
-
Working with one-liners for text processing and pattern matching with AWK
- Selective printing of lines with AWK
- Modifying line spacing in a file with AWK
- Numbering and calculations with AWK
- Selective deletion of certain lines in a file with AWK
- String operation on selected lines with AWK
- Array creation with AWK one-liner
- Text conversion and substitution in files with AWK
- One-liners for system administrators
- Use case examples of pattern matching using AWK
- Summary
- Further reading
-
Working with one-liners for text processing and pattern matching with AWK
Product information
- Title: Learning AWK Programming
- Author(s):
- Release date: March 2018
- Publisher(s): Packt Publishing
- ISBN: 9781788391030
You might also like
book
Effective awk Programming, 3rd Edition
Effective awk Programming,3rd Edition, focuses entirely on awk, exploring it in the greatest depth of the …
book
Effective awk Programming, 4th Edition
This practical guide serves as both a reference and tutorial for POSIX-standard awk and for the …
book
The AWK Programming Language, 2nd Edition
Awk was developed in 1977 at Bell Labs, and it’s still a remarkably useful tool for …
book
sed, awk and Regular Expressions Pocket Reference
For people who create and modify text files, sed and awk are power tools for editing. …