The "-v" option to awk has to come before the actual awk program. It lets you associate a variable name with a given value inside the program. For example:
Code:
$ awk -v magic="xyzzy" 'BEGIN {print magic}' *
This tells awk that inside the program you give it, the variable "magic" will have the value "xyzzy".
Incidently, the reason your technique will not work is because the awk program itself is the part of the command line in single quotes. Single quotes on the command line turn off the meanings of most special characters like $. You cannot expand variables in single quotes.
You can also use ENVIRON inside an awk program:
Code:
awk 'BEGIN {print ENVIRON["HOME"]}' *
This lets you access shell variables.