awk'{print $2 ", " $1}'<file># concatenate fields 2 and 1 with string
awk'{print $(NF)}'file# print last column
awk-F'='{print$2}# use = as field separator
awk-f<awkprogram><file># execute awk program script for file
awk'{print $(NF-2)}'# arithemtic operations
int(3.9)# returns 3rand()# returns random float 0 <= f < 1int(rand()*6)+1# simulate rolling 6-sided diesrand()# seed random number generator, if arg. omitted use curr. time + date\pi=atan2(0,-1)
length()# length of stringindex()# position of substring in string, 0 if not found...sub(regex,newval[,string])# replace first occurancegsub(regex,newval[,string])# replace all occurancessplit(string,array[,regex])
Awk arrays are associative (dictionaries). Only one-dimensional arrays supported, multi-dimensional ones can be simulated by nesting arrays. Awk supports
Indexed arrays
Associative arrays
12
a["x"]=1;a["y"]=2;a["z"]=3for(<index>in<array>){}
There is no easy way to iterate over values in an array.