Add 'bash/internal_output_tee.bash'
This commit is contained in:
8
bash/internal_output_tee.bash
Normal file
8
bash/internal_output_tee.bash
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
LOGFILE="/my/log/file.log"
|
||||||
|
exec > >(tee "$LOGFILE") 2>&1
|
||||||
|
# This will tee both stout and sterr to terminal and logfile for the entirity of the script.
|
||||||
|
# Useful if you cannot / don't want to wrap the script execution in a redirect at call time.
|
||||||
|
# Stops you having to put '...| tee $LOGFILE 2>&1' on every other line of your script.
|
||||||
|
#
|
||||||
Reference in New Issue
Block a user