redirect all output in a bash script when using set -x

后端 未结 4 560
青春惊慌失措
青春惊慌失措 2020-12-13 09:05

I have a bash script that has set -x in it. Is it possible to redirect the debug prints of this script and all its output to a file? Ideally I would like to do

4条回答
  •  时光取名叫无心
    2020-12-13 09:45

    To redirect stderr and stdout:

    exec &>> $LOG_FILE_NAME
    

    If you want to append to file. To overwrite file:

    exec &> $LOG_FILE_NAME
    

提交回复
热议问题