重定向 bash 命令的输出控制台消息

redirect output console message of bash command

提问人:hruday 提问时间:10/5/2020 更新时间:10/5/2020 访问量:146

问:

我执行以下命令

bash -c 'comm -12 <(sort vms1.txt) <(sort vms2.txt)'

它给出以下输出

sort: cannot read: vms1.txt: No such file or directory
sort: cannot read: vms2.txt: No such file or directory

如何抑制上述消息?我尝试了stderr重定向方法,但没有用

bash -c 'comm -12 <(sort vms1.txt) <(sort vms2.txt) 2>&-'

关键是禁止显示错误消息,并且不想在 stdout 上显示。

bash stdout stderr suppressmessage

评论

1赞 Abelisto 10/5/2020
bash -c 'comm -12 <(sort vms1.txt 2>/dev/null) <(sort vms2.txt 2>/dev/null)'
0赞 hruday 10/5/2020
谢谢@Abelisto它确实有帮助

答: 暂无答案