I want to execute a long running command in bash shell, and both capture its exit status, and tee its output.
So I do this
command | tee out.txt
ST=$?
The problem is that the variable ST captures the exit status of tee and not of command. How can I solve this?
Note that command is long running and redirecting the output to a file to view it later is not a good solution for me.