Using awk with variables

Pass variables to awk with the -v flag.

x=3
A=`echo $A|awk -v y=$x '{print y}'`
echo $A

Leave a Comment