Note that the opening single-quote for the awk program operand MUST be on the same line as awk .
Note that the 1st field's mutually exclusive failed tests are of the form err = " message" and all subsequent failed tests are of the form err = err "message" .
Note that the leading <space> character in each of the error messages is crucial.
Note that if you're trying to test whether or not id is an alphanumeric string, you're using the wrong ERE. You should use something more like:
if(id !~ /^[[:alnum:]]*$/)
which will add an error message to err if there are any non-alphanumeric characters in id . Your current test will also allow colon, semicolon, less-than, equal-sign, greater-than, question-mark, and at-sign characters in id if you're using a codeset that is a superset of US-ASCII and is an ERE producing undefined results if you're using an EBCDIC codeset.
As always, if you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk .