Reputation: 3380
line=catsanddogs;awk -v var="$line" RS= '$3=="`var`"' master_file.sql > jaylog
awk: cmd. line:1: RS=
awk: cmd. line:1: ^ unexpected newline or end of string
I'm trying to incorporate a variable into this statement but I can't get the syntax to work correctly.
The following, of course, works fine:
awk -v RS= '$3=="`catsanddogs`"' master_file.sql > jaylog
Upvotes: 0
Views: 33
Reputation: 780724
There are two problems.
First, since you didn't use the -v
option before the variable assignment, awk
thinks the argument RS=
is the script, and that's not a valid awk
script.
Second, awk
doesn't expand variables inside quoted strings, they're treated literally. You need to concatenate the var
variable to the backtick strings, not put it inside the string.
awk -v var="$line" -v RS= '$3=="`" var "`"' master_file.sql > jaylog
Upvotes: 3