Jul 29, 2003 #1 PuPPeT2 Programmer Jul 28, 2003 5 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 Jul 28, 2003 5 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 Apr 8, 2001 1,294 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 Jul 28, 2003 5 US very cool - thank you Upvote 0 Downvote
Jul 29, 2003 #5 grega Programmer Feb 2, 2000 932 GB There's a few ways. Read my FAQ ... Faq271-1281 Greg. Upvote 0 Downvote
Jul 29, 2003 #6 vgersh99 Programmer Jul 27, 2000 2,146 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> | +----------------------------+