In my bash script I have:
patterns=( "somee? +pattern" "Another +here" )
awk -v l="$line" -f horsepower <(printf '%s\n' "${patterns[@]}") <<<"$stdout"
, so sending to awk script two files, first being process substitution output of
printf on ${patterns[@]} array, and second being HERESTRING feed from
$stdout variable.
, then in that external awk script, named here horsepower I have the
following:
BEGIN {
...some initialization, not of importance for this question
}
# while reading first file, populate `patterns` array in awk
FNR==NR { patterns[$0]=""; next }
for (pat in patterns)
# match lines from `$stdout` on patterns sent from bash, and save them in `a_rem`
# array, for later output in END block.
$0 ~ pat { a_rem[NR]=$0 }
# then follows END block
END {
...also non important
}
, but I am given notice about syntax error on for from above for (pat in
patterns).
What am I doing wrong? Also, is awk getting correct first, second files from
my bash script, using that method of <(), and <<<"$stdout"?
I have to mention, all of this was working when I was using literal regexes in
awk script, but the moment I introduced that for (pat in patterns), and
adding that <() in bash(<<<"$stdout" was ok!), I am getting this syntax
error.