By andresgom
Hi everybody.
I’m using the AWK command in a simple script.
I’m using this command like this:
$ cat /etc/passwd | awk -F: ‘$1==”proxy” {print}’
Its useful, I have this output:
proxy:x:13:13:proxy:/bin:/bin/sh
But now I need to use a variable instead the string “proxy”, but now I’m trying something like this, but it doesnt work:
I’m using the AWK command in a simple script.
I’m using this command like this:
$ cat /etc/passwd | awk -F: ‘$1==”proxy” {print}’
Its useful, I have this output:
proxy:x:13:13:proxy:/bin:/bin/sh
But now I need to use a variable instead the string “proxy”, but now I’m trying something like this, but it doesnt work:
THEVARIABLE=proxy
cat /etc/passwd | awk -F: ‘$1==$THEVARIABLE {print}’
The output it’s very different, its like the comparison “$1==”proxy” doesn’t work.
Can anybody hel me? how can I use a Variable into a awk or grep expression?
thanks!!
Andres