Redirect stderr and stdout in Bash

后端 未结 15 905
日久生厌
日久生厌 2020-11-22 08:18

I want to redirect both stdout and stderr of a process to a single file. How do I do that in Bash?

15条回答
  •  青春惊慌失措
    2020-11-22 08:44

    In situations when you consider using things like exec 2>&1 I find easier to read if possible rewriting code using bash functions like this:

    function myfunc(){
      [...]
    }
    
    myfunc &>mylog.log
    

提交回复
热议问题