awk regex with variable
Hy!
I've a problem with bash scripting and can't solve it. I was searching for a solution but can't find anything which answers my question. ... maybe I'm to stupid to understand it at the moment ... so I hope there is anybody who can help me.
I will check the state of an port (in this case 125) with the followig line:
>PORT_STATE=`netstat -nat | awk '/0.0.0.0:125/{print $6}'`
>echo $PORT_STATE
LISTEN
Now I'm trying to set the port as an variable like this:
>PORT=125
>PORT_STATE=`netstat -nat | awk '/0.0.0.0:$PORT/{print $6}'`
>echo $PORT_STATE
But this dosn't work and I don't know how to do it correctly.
Please help!
Thanks!
bertl1982
|