Jul 29, 2003 #1 PuPPeT2 Programmer Joined Jul 28, 2003 Messages 5 Location US is there a way to pass a variable into an awk statement from out site the statement? variable="hello world" cat file| awk ' { print "variable from outside awk:"variable }' where would we all be w/out awk, sed and grep?
is there a way to pass a variable into an awk statement from out site the statement? variable="hello world" cat file| awk ' { print "variable from outside awk:"variable }' where would we all be w/out awk, sed and grep?
Jul 29, 2003 Thread starter #2 PuPPeT2 Programmer Joined Jul 28, 2003 Messages 5 Location US i guess i could have asked if there was a way to reference variables from outside an awk statement in an awk statement too or perhaps instead Upvote 0 Downvote
i guess i could have asked if there was a way to reference variables from outside an awk statement in an awk statement too or perhaps instead
Jul 29, 2003 #3 CaKiwi Programmer Joined Apr 8, 2001 Messages 1,294 Location US Like this cat file| awk -v var=$variable ' { print "variable from outside awk:" var }' CaKiwi "I love mankind, it's people I can't stand" - Linus Van Pelt Upvote 0 Downvote
Like this cat file| awk -v var=$variable ' { print "variable from outside awk:" var }' CaKiwi "I love mankind, it's people I can't stand" - Linus Van Pelt
Jul 29, 2003 Thread starter #4 PuPPeT2 Programmer Joined Jul 28, 2003 Messages 5 Location US very cool - thank you Upvote 0 Downvote
Jul 29, 2003 #5 grega Programmer Joined Feb 2, 2000 Messages 932 Location GB There's a few ways. Read my FAQ ... Faq271-1281 Greg. Upvote 0 Downvote
Jul 29, 2003 #6 vgersh99 Programmer Joined Jul 27, 2000 Messages 2,146 Location US UUOC - sorry for nit-pickin' awk -v var=$variable '{print "variable from outside awk:" var }' file vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+ Upvote 0 Downvote
UUOC - sorry for nit-pickin' awk -v var=$variable '{print "variable from outside awk:" var }' file vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+