How to store the output of a command in a variable at the same time as printing the output? January 2, 2024 by Tarik Use tee to direct it straight to screen instead of stdout $ var=$(echo hi | tee /dev/tty) hi $ echo $var hi