The common solution is to use the -v option to define an awk variable giving it the value of the shell variable: {{{ sh # 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 / /. {{{ sh #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: {{{ sh export FOO=bar awk 'BEGIN{print ENVIRON["FOO"]}' }}} If this is not enough have a look at the [[http://awk.freeshell.org/comp.lang.awk_FAQ#toc2|comp.lang.awk FAQ]]
Summary:
This change is a minor edit.
Username: