[英]What is the difference between “>” and “&>” in bash?
In bash we have 3 stream types:在 bash 中,我们有 3 种流类型:
So, while executing some program i can use these streams (eg i can redirect them from console to a file or smth like /dev/null, etc):因此,在执行某些程序时,我可以使用这些流(例如,我可以将它们从控制台重定向到文件或类似 /dev/null 等的文件):
# only errors from STDERR will be shown, STDOUT will be moved to /dev/null
command > /dev/null
# only STDOUT will be shown, STDERR will be moved to /dev/null
command 2> /dev/null
I saw that some people write command &> /dev/null
看到有人写
command &> /dev/null
What is the difference between >
and &>
in bash? bash 中
>
和&>
什么区别?
what is the difference between ">" and "&>" in bash?
bash 中的“>”和“&>”有什么区别?
It's a bashism that redirects both stdout
and stderr
.这是一种重定向
stdout
和stderr
的bashism。 It can also be achieved with the more portable:它也可以通过更便携的方式来实现:
command > file 2>&1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.