The awk Programming Language*

(see man awk!)
awk [-F regexpr] -f progfile [-v asgn] [ arg ]
-F sets the field separator to the regular expression
-f Read the awk program from the progfile rather than the command line
-v Perform the awk assignment asgn before executing the awk program

An awk program consist of repeated statements that can be preceded by initializations and can be ended with final actions. Actions are enclosed in { }. The awk commands are placed in single quotes like sed commands.

BEGIN { action } - perform the actions before processing the file
END {action} - perform the actions after processing
{ action } - perform actions to each input record
pattern [ {action} ] - perform action on only those records that match the pattern
pat1,pat2[{action}] - perform action in the range of records from pat1 to pat2

Rules for statements in an awk program:

Awk elements consist of constants (numbers and strings), variables, regular expressions, array elements, function calls, and parenthesized expressions.
Unlike the shell, mathematical operations do not need a call to expr.
User defined variables mimic the shell; however $0, $1, ... take on a different meaning.
Awk separates the entire input record into fields separated by whitespace. $1 is the first field, $2 is the second and $0 is the entire record.
The predefined variable FS. Assigning FS a different value (assignment statement or the -F flag), will cause awk to use that value as a separator.
Similarly, RS is the record separator and can be set to a single character. The default is \n.

Awk Operators

Control Structures

If statement is just like C's
if ( condition )
   Stmt1
else
   Stmt2

For statement is like C's NOT the shells

for (exp1; cond; exp2)
   Stmt

While Statement (equivalent to above for):
   exp1

while ( condition) {
   stmt
   exp2
}

awk Built-in functions

* This information is directly from Unix for the Impatient by Paul Abrahams and Bruce Larson