Passing a bash variable to awk in a shell script

Thursday, January 03, 2013 , , , 0 Comments

Many a times there is a need for passing shell variables inside a shell script to awk.

below is the way we have to pass it and the execution is done on solaris unix:

> setenv X "hello"
> echo $X | nawk -v str="${X}" '{print str}'
hello
>

 

0 comments: