Log script output to file and console
Several ways to log the output of a script to a file and console:
exec &> >(tee out.log)exec > >(tee -i "/tmp/$0.log")
exec 2>&1main() { ... }
main |& tee /tmp/$0.logLOG_FILE=/tmp/test.log
LOG_FILE=${0##*/}
LOG_FILE="/tmp/${LOG_FILE%.*}.log"
exec > >(tee "${LOG_FILE}") 2>&1