script 執行自己log 的紀錄

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

书籍推荐