Pass Shell Variables To awk
How do I pass shell variables to awk command or script under UNIX like operating systems?
The -v option can be used to pass shell variables to awk command. Consider the following simple example,
root="/webroot"
echo | awk -v r=$root '{ print "shell root value - " r}'