AWK basic usage
refs:
- Tutorialspointhttps://www.tutorialspoint.com/awk/awk_overview.htm)
- man page of gawk
# Overview
AWK is created by Alfred Aho, Peter Weinberger and Brian Kernghan from AT & T lab.
GAWK is the GNU distribution of AWK.
awk is a pattern scanning and processing language.
The routine of AWK:
- AWK reads a line from input stream and stores it in memory.
- All AWK commands are applied sequentially on the input.
- Repeat until the file reaches end.
# Structure:
|
|
- The BEGIN block is excuted at start-up only once (this block is optional)
- The second block is the body block, which is applied on each input line.
- END Block is like BEGIN, but excuted at the end.
# Command Line:
awk -f command.awk file.txt