在bash中,我们有3种streamtypes:
所以,当执行一些程序时,我可以使用pipe理这些stream(例如,我可以将它们从控制台redirect到一个文件或像/ dev / null等smth):
命令> / dev / null(仅显示STDERR中的错误,STDOUT将移至/ dev / null)命令2> / dev / null(enly将显示STDOUT,STDERR将移至/ dev / null)
我看到有些人写命令&> / dev / null
bash中的“>”和“&>”有什么区别?
bash中的“>”和“&>”有什么区别?
这是一个重定向stdout
和stderr
的bashism。 它也可以通过更便携的方式实现:
command > file 2>&1