I've been trying to read a file in bash, and keep all the lines in a single variable, printing it at once after the loop:
cat /tmp/myfile | while read line; do
However the output was only: EVIL_BASH, instead of having the lines of the /tmp/myfile appended.
WHAT THE HELL?
Because of the PIPE, the whole 'while' loop runs in another subshell. This means that $all outside the loopÂ is not the same $all from within the loop!
Sounds simply like scoping (as in perl), but a really awkward one. Beware.