Awk Scripting Tutorial. AWK is an interpreted programming language. It is very powerful and specially designed for text processing. Its name is derived from the family names of its authors – Alfred Aho, Peter Weinberger, and Brian Kernighan.
The version of AWK that GNU/Linux distributes is written and maintained by the Free Software Foundation (FSF); it is often referred to as GNU AWK.
Types of AWK
AWK – Original AWK from AT & T Laboratory.
NAWK – Newer and improved version of AWK from AT & T Laboratory.
GAWK – It is GNU AWK. All GNU/Linux distributions ship GAWK. It is fully compatible with AWK and NAWK.
Awk Scripting Tutorial
Installation Using Package Manager
Installation from Source Code
AWK WORKFLOW
Program Structure
BASIC SYNTAX
Command Line AWK
Program File AWK
AWK Standard Options
BASIC EXAMPLES
Column or Field Printing
All Lines Printing
Printing Columns by Pattern
Column in Any Order Printing
Counting and Printing Matched Pattern
Printing Lines with More than 18 Characters
BUILT-IN VARIABLES
Standard AWK Variables
GNU AWK Specific Variables
OPERATORS
Arithmetic Operators
Increment and Decrement Operators
Assignment Operators
Relational Operators
Logical Operators
Ternary Operator
Unary Operators
Exponential Operators
String Concatenation Operator
Array Membership Operator
Regular Expression Operators
REGULAR EXPRESSIONS
Dot
Start of Line
End of Line
Match Character Set
Exclusive Set
Alteration
Zero or One Occurrence
Zero or More Occurrence
One or More Occurrence
ARRAYS
Creating Array
Deleting Array Elements
Multi-Dimensional Arrays
CONTROL FLOW
If Statement
If-Else Statement
If-Else-If Ladder
LOOPS
For Loop
While Loop
Do-While Loop
Break Statement
Continue Statement
Exit Statement
BUILT-IN FUNCTIONS
Arithmetic Functions
String Functions
Time Functions
Bit Manipulation Functions
Miscellaneous Functions
USER-DEFINED FUNCTIONS
OUTPUT REDIRECTION
Redirection Operator
Append Operator
Pipe
Two-Way Communication
PRETTY PRINTING
Escape Sequences
Format Specifier
Optional Parameters with %
Delete blank lines from a file – AWK
Fields using AWK
Particular line numbers text using AWK
Replacing text using AWK