From b1fdb7bfe8af4f26a48dbdab9834d98913022b7f Mon Sep 17 00:00:00 2001 From: daryl Date: Tue, 31 May 2022 13:55:57 +0930 Subject: [PATCH] Add 'bash/internal_output_tee.bash' --- bash/internal_output_tee.bash | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 bash/internal_output_tee.bash diff --git a/bash/internal_output_tee.bash b/bash/internal_output_tee.bash new file mode 100644 index 0000000..a8cd8cf --- /dev/null +++ b/bash/internal_output_tee.bash @@ -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. +# \ No newline at end of file