[英]What does “/dev/null” mean at the end of shell commands
What is the difference between the following commands? 以下命令有什么区别?
ssh myhostname "command1; command2;...commandn;" 2>/dev/null
ssh myhostname "command1; command2;...commandn;"
what does 2>
mean? 2>
是什么意思?
what does /dev/null
mean? /dev/null
是什么意思? I read somewhere that result of command will be write to file /dev/null
instead of console! 我在某处读到命令的结果将写入文件
/dev/null
而不是控制台! Is it right? 这样对吗? It seems strange for me that the name of file be
null
! 对我来说,文件的名称为
null
似乎很奇怪!
2>
means "redirect standard-error" to the given file. 2>
表示“将标准错误重定向”到给定文件。
/dev/null
is the null file. /dev/null
是空文件。 Anything written to it is discarded. 写入的任何内容都将被丢弃。
Together they mean "throw away any error messages". 他们一起意味着“扔掉任何错误信息”。
1 is stdout. 1是标准输出。 2 is stderr.
2是stderr。
Then sometimes you find 2>&1
, that means redirecting stderr to stdout. 然后有时你会发现
2>&1
,这意味着将stderr重定向到stdout。
'/dev/null' essentially means "into the void", discarded. '/ dev / null'本质上意味着“进入虚空”,被丢弃。 The
2
you mention refers to error output, where it should be directed. 你提到的
2
是指错误输出,应该指向它。
2> means sending standard error to something 2>表示发送标准错误
/dev/null means a bin / dev / null表示bin
1) Pipe everything on standard error to /dev/null (so ignore it and don't display it) 1)将标准错误上的所有内容传递给/ dev / null(因此忽略它并且不显示它)
2) Dev null just points to nowhere, pipe anything to that, and it disappears. 2)Dev null只指向无处,管道任何东西,它消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.