How do we pass multiple arguments into awk

How do we pass multiple arguments into awk :

name=john
age=12

now i have to pass both age and name into awk.. how to do it?

like : awk -v var=...

Use -v

awk -v name=john -v age=12 'BEGIN{print name, age}'

If you don't need to use the variable in the BEGIN patten, you can also do :

awk 'awk script code' name=john age=12 inputfile

Jean-Pierre.

thanks a lot guys

So despite the "BEGIN" drawback, this one has the advantage of being more portable. If you use GNU or Sun's xpg4-awk, -v will work.