log_file="log_file.txt" if [ -e $log_file ];then rm $log_file fi exec &> >(tee -a "$log_file") echo This will be logged to the file and to the screen