invocation: $ awk '/milk/ {print "drinking milk in this way " $2}' file1 file2 ... ----------------------------------------------------------------------- $ awk -f awk-file file1 file2 .... $ cat awk-file /milk/ {print "drinking milk in this way " $2} $ ----------------------------------------------------------------------- $ ./awk-prog file1 file2 ... $ ls -al awk-prog -rwxr-xr-x 1 klim sys 72 Nov 27 16:11 awk-prog $ cat awk-prog #! /usr/local/bin/gawk -f /milk/ {print "drinking milk in this way " $2} $ which gawk /usr/local/bin/gawk $ -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= The following is extracted from the man page of gawk. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= body of the program An AWK program consists of a sequence of pattern-action statements and optional function definitions. pattern { action statements } function name(parameter list) { statements } Patterns BEGIN END /regular expression/ relational expression pattern && pattern pattern || pattern pattern ? pattern : pattern (pattern) ! pattern pattern1, pattern2 The control statements are as follows: if (condition) statement [ else statement ] while (condition) statement do statement while (condition) for (expr1; expr2; expr3) statement for (var in array) statement break continue delete array[index] delete array exit [ expression ] { statements } I/O Statements getline var getline var > logdir/myhome.html") }'