Redirect stderr and stdout in Bash

后端 未结 15 1058
日久生厌
日久生厌 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 09:00

    Curiously, this works:

    yourcommand &> filename
    

    But this gives a syntax error:

    yourcommand &>> filename
    syntax error near unexpected token `>'
    

    You have to use:

    yourcommand 1>> filename 2>&1
    

提交回复
热议问题