I try to use tee to save output in file like:
myapp | tee log.txt
But I have a problem with checking of exit. Previous code:
Use PIPESTATUS
myapp | tee log.txt if [ $PIPESTATUS[0] -eq 0 ] then .....