PassingAShellVariable

The common solution is to use the -v option to define an awk variable giving it the value of the shell variable:

# correct quoting for a bourne like shell:
shellvariable=foo
awk -v awkvar="$shellvariable" 'BEGIN{print awkvar}' 

If you want to pass a pattern as a variable take care that the pattern is a string, so the \ are interpreted twice(ie "\." define the string '.'), while they are only intrepreted once within / /.

#version using a constant
awk '/foo\./{print}'
#version with a variable
pattern='foo\\.'  
awk -v pattern="$pattern" '$0 ~ pattern{print}'

If your variable is an environment variable then you can access it using the ENVIRON array:

export FOO=bar
awk 'BEGIN{print ENVIRON["FOO"]}'

If this is not enough have a look at the comp.lang.awk FAQ