In a bash script, how can I redirect all standard outputs to a log file and tee
the output on the screen using exec
?
log_file="$HOME/logs/install.txt-`date +'%Y-%m-%d_%H-%M-%S'`"
[ -f "$log_file" ] || touch "$log_file"
exec 1>> $log_file 2>&1
This code redirect all the log to the log file but not to the screen .