an awk program is a series of //pattern { actions }// statements;\\ ie if the input line matchs pattern then the actions are performed. {{{awk /abc/ { print } }}} would only print lines that contained the string ''abc''. Lines are split into fields separated by whitespace - $1 is the first field; $2 the second ...\\ and $0 is the whole line. Comments can follow the # symbol. {{{awk # print those lines where "awk" appears in the first field. $1 ~ /awk/ { print $0; } }}} An omited pattern matchs every line and an omitted action just prints the line.\\ The special pattern ''END'' is done after all data is read; so to print the sum of the first column: {{{awk { sum = sum + $1 } END { print sum } }}} To also find the maximum value of field $1: {{{awk { sum = sum + $1 } $1 > max { max = $1 } END{ print "sum = " sum; print "max value = " max; } }}} For terse concise summary see:\\ http://www.cs.princeton.edu/courses/archive/spring12/cos333/awk.help\\ most Extensive list: [[http://awk.freeshell.org/?action=index|AwkChannelWiki: Index of all pages]]
Summary:
This change is a minor edit.
Username: