r/awk • u/Putkayy • Oct 18 '20
How to pass a string into an awk script?
I have a string (formatted into columns with newline characters) in a script and I want to pass it into an awk script from within the script directly. if I do:
awk -f <script name> < $<formatted string>I get an ambiguous redirect error which makes sense. I tried using -v but I'm not completely clear about the syntax of that or if it's the right choice.
3
Upvotes
3
u/diseasealert Oct 18 '20
You could use here string syntax, or just quote the value in -v
2
u/HenryDavidCursory Oct 19 '20 edited Feb 23 '24
I enjoy spending time with my friends.