I have a challenge with a variable value changed in a for loop and the value of that variable after the for loop and using tee
SCRIPT_1:
STATUS=9
for SESSION in A B C
do
STATUS=5
echo "SESSION=$SESSION STATUS=$STATUS"
done
echo "STATUS=$STATUS"
output script_1 is:
SESSION=A STATUS=5
SESSION=B STATUS=5
SESSION=C STATUS=5
STATUS=5
SRIPT_2:
STATUS=9
for SESSION in A B C
do
STATUS=5
echo "SESSION=$SESSION STATUS=$STATUS"
done | tee /tmp/ses.txt
echo "STATUS=$STATUS"
output_2 is:
SESSION=A STATUS=5
SESSION=B STATUS=5
SESSION=C STATUS=5
STATUS=9
Why a different output when using tee after done command.