i need to parse a number of lines without entering a subshell
cat << EOF | while read -r cmd
sleep 100
sleep 110
sleep 120
EOF
do
echo $cmd
done
will result:
sleep 100
sleep 110
sleep 120
and it is working, but problem is i need the result outside subshell (be cause i need the results after), tried with for instead of while, but then it won’t parse lines but words:
for cmd in `cat << EOF
sleep 100
sleep 110
sleep 120
EOF`
do
echo $cmd
done
will result:
sleep
100
sleep
110
sleep
120
so, any ideea how to do that ?
Pipes create a subshell. I/O redirection (including here-documents) doesn’t.