awk scripting notes

From thelinuxwiki
Jump to: navigation, search

compound logical statement

$ echo "1 2 3" | awk '{for (i=1; i<=NF; i++) if (($i=="1") && ($(i+1)=="2")) print $(i+2)}'
3