awk is a domain-specific language and command for text processing available on Unix-compatible systems.
gawk is the GNU AWK and all Linux distributions come with it.
This is a brief tutorial for
awk covering the most common use-cases.
awk reads input line by line from a file, pipe, or stdin and executes a program on each line.
An input line has a number of fields separated by white space or by regular expression
The fields are denoted
$2, and so on and
$0 denotes the entire line.
FS is not set, the input line is split into one field per character.
awk <options> <program> <input_file>
Here are some options for
awk command that you most likely need to know about them.
||Specifies the file containing the awk program.|
||Specifies the regular expression for separating fields.|
An action is a sequence of statements.
|Prints data on standard output.|
||Prints data on standard output.|
||Prints Hello, World! on stdout.|
||Prints the second and fourth columns separated by tab.|