This one has me stumped.
#!/bin/ksh
AWKSCRIPT='END { print "all done"; }'
OUTPUT=`echo hello world | awk '$AWKSCRIPT'`
RETVAL=$?
echo "running echo hello world | awk '$AWKSCRIPT'"
echo "Output = $OUTPUT"
echo "returned = $RETVAL"
The output is
$ ./kshawk.ksh
Output = hello world
returned = 0
(I was expecting to see "Output = all done")
It looks like the interpreter is not substituting the AWKSCRIPT variable when evaluating the expression (I get the same behaviour if I use $(...) instead of backticks).
While I could dump AWKSCRIPT to a temporary file - this would have to be hardcoded too?
Any ideas how to interpolate a variable within backticks?