I've seen a few answers to similar questions here, but non seem to address my specific issue.
I have a bash script which generates a list of variables that I want sent within an awk command. My issue is, that as soon as there more than one variables that I am trying to inject, awk throws a "unexpected newline or end of string" error. I've distilled the problem down to the following 2 lines of code:
MYVARS="VAR1=1; VAR2=2;"
awk '{'$MYVARS'}'
So if I run:
MYVARS="VAR1=1;"
awk '{'$MYVARS'}'
all is fine.
Can someone please explain what is going on, and preferably how to achieve what I want?
Please note that whilst this is similar to other questions - this is unique in so far as I am attempting to use a single bash variable to pass in multiple awk variables. Please do not close this question unless the question you direct me to specifically deals with this problem. My code works fine if I pass in a single variable.