I have a script, in which a script snippet is:
x=3 awk \'$2=$x{print $1}\' infile
The external variable is x,
x
but it p
awk has a -v option for this purpose, or as @nevelis mentions, just use double quotes:
awk
-v
awk -v x=3 ' $2==x {print $1} '