In a Bash script, I need to redirect the output of a command to a variable, while also streaming unbuffered output to the terminal.
I've tried this:
output=$(command 2>&1 | tee "$(tty)")
but this doesn't output anything to the terminal.
I've also tried
mytty=$(tty) output=$(command 2>&1 | tee $mytty)
This gives me the error "tee: /dev/tty1: Permission denied".
The current OS is OpenSUSE 15.0 and I do not have sudo/root rights.