Description #
AWK is a text-processing and pattern-matching language used in Unix-based systems to extract and manipulate structured data from files or streams.
History #
AWK was created in 1977 at Bell Labs by Alfred Aho, Peter Weinberger, and Brian Kernighan (the name “AWK” is an acronym of their surnames). It was designed as a powerful one-liner language for pattern-action statements and became a core utility in Unix toolchains.
Hello World Code #
BEGIN { print "Hello, World!" }
How to Run #
Option 1: Online
https://awk.js.org/
Option 2: Local
AWK is pre-installed on most Unix/Linux/macOS systems.
To run:
awk 'BEGIN { print "Hello, World!" }'
Or save in a file:
awk -f hello.awk
Key Concepts #
- Pattern-action language for text processing
- Line-by-line input scanning
- Interpreted, with single-pass execution
- Uses associative arrays and built-in variables
- Automatically splits input into fields
- Regular expression support
- Frequently used in shell scripts and pipelines
- Includes
gawk
(GNU AWK) for extended features - Loosely typed and highly concise
- Functional and declarative programming styles supported
Try It Online #
Fun Facts #
- AWK laid the foundation for languages like Perl.
- Often used in combination with grep, sed, and bash for data wrangling.
- Still used extensively for log parsing, ETL scripts, and quick analytics in Unix environments.
Resources #
GNU AWK Manual
AWK Tutorial (Griffiths & Dougherty)
Online AWK Runner
GitHub GAWK Source