Some times we need to pass external shell variables inside awk statement. Here is a way to do it
suppose I want to use $user in my awk command
$ export user=uid #$user is defined
Pass it to awk command with -v option
$ cat /etc/passwd|tail -1|awk -v var=$user -F":" '{print "Your " var " is " $1}'
o/p: Your uid is guruss1
Thursday 9 July 2009
How to use an external variable inside awk command?
Posted on 04:15 by Unknown
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment