![Jonas Berlin on Twitter: "How to pipe stdout & stderr of a #bash script both to stdout and to a file: exec 3>&1 coproc tee -a logfile >&3 trap "exec >&3 2>&3 { Jonas Berlin on Twitter: "How to pipe stdout & stderr of a #bash script both to stdout and to a file: exec 3>&1 coproc tee -a logfile >&3 trap "exec >&3 2>&3 {](https://pbs.twimg.com/media/EajOaICWsAAsRUx.jpg)
Jonas Berlin on Twitter: "How to pipe stdout & stderr of a #bash script both to stdout and to a file: exec 3>&1 coproc tee -a logfile >&3 trap "exec >&3 2>&3 {
![Bash - Redirect both standard output and standard error to same file - Linux Tutorials - Learn Linux Configuration Bash - Redirect both standard output and standard error to same file - Linux Tutorials - Learn Linux Configuration](https://linuxconfig.org/wp-content/uploads/2013/04/01-bash-redirect-both-standard-output-and-standard-error-to-same-file.png)
Bash - Redirect both standard output and standard error to same file - Linux Tutorials - Learn Linux Configuration
![bash - why ">/dev/null" works differently when it's used for a command line and for a file? - Stack Overflow bash - why ">/dev/null" works differently when it's used for a command line and for a file? - Stack Overflow](https://i.stack.imgur.com/LCcxQ.png)