I have a big file called file1
on my ESX host. I run some awk
command on the file and extract useful blocks of data into a variable which works fine on the busybox shell.
Now I want to read from that variable (info
) line by line, change something and write to a different file.
info=$(awk '/pat1/{flag=1}/pat2/{flag=0}flag' file1) -> works fine
while IFS= read -r line; do
printf '%s\n' "$line"
done <<< "$info"
but the while loop doesn't work. Get error as "unexpected redirection". I also tried `done << "$info". Then I get error as
syntax error: unexpected end of file (expecting "}")
So basically how to read from a variable line by line?
Thanks Would appreciate your response
info
? – berndbausch Mar 20 '21 at 12:02