Redirecting command output to a variable in bash fails

前端 未结 2 1904
醉酒成梦
醉酒成梦 2020-12-09 08:13

I\'m trying to redirect command output to a variable:

OUTPUT=$(sudo apache2ctl configtest)

and then to read it:

echo $OUTPU         


        
2条回答
  •  庸人自扰
    2020-12-09 08:43

    maybe the output goes to stderr, not stdout?

    try this: OUTPUT=$(sudo apache2ctl configtest 2>&1)

提交回复
热议问题