awk
Last modified: December 2, 2006
This page refers to Awk, a full-featured text processing language with a syntax reminiscent of C.
Awk
Awk breaks each line of input passed to it into fields. By default, a field is a string of consecutive characters separated by whitespace, though there are options for changing the delimiter. Awk parses and operates on each separate field. This makes awk ideal for handling structured text files – especially tables – data organized into consistent chunks, such as rows and columns.
Strong quoting (single quotes) and curly brackets enclose segments of awk code within a shell script.
echo one two | awk '{print $1}'
# one
echo one two | awk '{print $2}'
# two
awk '{print $3}' $filename
# Prints field #3 of file $filename to stdout.
awk '{print $1 $5 $6}' $filename
# Prints fields #1, #5, and #6 of file $filename.
References:


Recent Comments