LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Run AWK script on contents of a variable (https://www.linuxquestions.org/questions/linux-newbie-8/run-awk-script-on-contents-of-a-variable-739113/)

EmrldDrgn 07-10-2009 03:43 AM

Run AWK script on contents of a variable
 
I have an AWK script (tiny, nothing special, passed on command line) that I want to run with the contents of a variable instead of the contents of a file. How can I do this? It seems like it should be really simple, but I've been trying for hours!

Thanks!

colucix 07-10-2009 04:06 AM

Maybe something like
Code:

echo $my_var | awk -f script.awk

EmrldDrgn 07-10-2009 04:07 AM

As always, I figured it out right after posting. Unless someone knows a better way than doing:

echo "$var" | awk '{script}'

?

xeleema 07-10-2009 05:05 AM

Jeepers!
 
Holy cow!
/me facepalm
I've got a script I've been working on for a week or so, and I kept scratching my head on something similar!

Thanks guys!


All times are GMT -5. The time now is 11:24 PM.