Awk

Most powerful linux command

Meant to work with cut-able files or structured data

Don't use for unstructured data

awk is more of a language than merely a command

It likely will require more practice thanthe other commands

Etymology
Name derived from


 * Aho
 * Weinberger
 * Kernigan

Kernigan was highly influential on the development of the C language

Command structure
Awk commands are always in single quotes
 * awk '$SEARCHCRITERIA $ACTIONS' file

Example

 * awk '$2=="Dairy" {print $1, $3}
 * If the second field is dairy then print fields 1 and 3
 * cat gdbase2 | awk '$2=="Dairy" || $2/[Vv]eg/ {print $1, $2}

Awk command file syntax
BEGIN {

//done before oging through file

print "My Groceries List:"

print "====================="

} //go to stuff that is actually done

{

//done for every line in file

if($2=="Dairy" || $2~/[vV]eg/){

print "Item: " $1, "Total item:" $3*$4

}

print $0

}

END {

//code done at end of file

print "====================="

}

Files
files are .awk, this is a non-binding convention