Welcome.
You'll need to look at the different styles of quoting. The single quotes ' ' mean to use everything between them as a a literal. The double quotes " " mean to interpret what's between them through the shell first. The latter is what you want since it will allow you to put a variable in there first. With
awk you can assign environment variables to
awk variables using -v
Code:
interface="wlan0"
iwconfig 2>&1 | grep "$interface"
iwconfig 2>&1 | awk -v i=$interface '$0 ~ i { print $1 }'
Compare:
Code:
interface="wlan0"
echo '$interface'
echo "$interface"