Passing a bash variable to awk in a shell script

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}'


No comments:

Post a Comment