Storing the stdout output of a command in a variable and displaying it is simple: OUTPUT=$(command) echo $OUTPUT If you have longer running commands where you want to display stdout in realtime and also store it in a variable you can tee the output to stderr: OUTPUT=$(command | tee /dev/stderr) OUTPUT=$(command | tee /proc/self/fd/2) OUTPUT=$(command…