I found a great solution at Redirect all subsequent commands' stderr using exec.
I used the example:
exec > >(tee $somelog) 2>&1
...and managed to get everything to tee
great. Now, how to I turn it off again?
I found a great solution at Redirect all subsequent commands' stderr using exec.
I used the example:
exec > >(tee $somelog) 2>&1
...and managed to get everything to tee
great. Now, how to I turn it off again?
The best solution if you plan it in advance is probably to save the descriptors first, or to do your redirections in a subsidiary scope, as in the question linked in the comments.
If you didn't do that, though, then you can restore writing directly to the terminal with:
exec > $(tty)
provided that you haven't redirected standard input as well.
If you have redirected standard input, you can use:
exec > /dev/tty
, which is also fractionally faster.
Those reset standard output to the terminal. To reset standard error specifically, use:
exec 2> ...
for whichever option you chose from above.
If you're just stuck and want to get out of it, note that simply exiting and restarting the shell will get you back to normal as well.