Skip to main content
3 of 3
stderr
sebasth
  • 15.8k
  • 6
  • 53
  • 71

Use tee. For example:

command 2>&1 | tee file.txt

Which runs command redirecting SDTERR to SDTOUT. tee copies STDIN to both STDOUT and to file file.txt.

In bash you can use process substitution in following way to copy output to $LOG:

exec &> >(tee $LOG)

However this bashism won't work on other shells.

sebasth
  • 15.8k
  • 6
  • 53
  • 71