I have a loop that processes a bunch of files within a dir. I would like to input the filename into the file it processes, but I'm getting an error. It works perfectly with the myvar syntax but I need that for obvious reasons.
Error
awk: cmd. line:1: RS=
awk: cmd. line:1: ^ unexpected newline or end of string
Command
for filename in $files
do
awk -v "myvar=${filename}"
RS= '/-- Ticket/{++i; print "PROMPT myvar Line ",
i ORS $0 ORS; i+=split($0, a, /\n/)+1}' ${filename}.txt
done
awk -v myvar="$filename" -v RS= '/-- Ticket/{++i; print "PROMPT", myvar, "Line ", i ORS $0 ORS; i+=split($0, a, /\n/)+1}' "$filename.txt"