为什么我不能将标准错误重定向到/ dev / null?

xxx:xxx 84> find / -name trans.log 2> /dev/null


产出


  查找:路径必须在表达式之前:2

最佳答案

我相信您正在寻找的是
此类命令中的大于号(>)将程序的输出重定向到某处。在这种情况下,某些内容将被重定向到/ dev / null,某些内容将被重定向到&1

xxx:xxx 84> find / -name trans.log >/dev/null 2>&1


如果您未指定数字,则假定使用标准输出流,但是您也可以重定向错误

> file redirects stdout to file
1> file redirects stdout to file
2> file redirects stderr to file
&> file redirects stdout and stderr to file


/dev/null是空设备,它将接受您想要的任何输入并将其丢弃。它可以用来抑制任何输出。

关于linux - 重定向到dev/null,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52739230/

10-14 19:16
查看更多