有人在linux为什么总喜欢写/dev/ null

WBOY
Release: 2016-06-06 20:26:46
Original
1167 people have browsed it

=1 >/dev/null 2>&1 &
为什么要写在/dev/null这里面呢,我测了下,输入a.txt有东西,但是输入到/dev/ null查看没东西啊

回复内容:

=1 >/dev/null 2>&1 &
为什么要写在/dev/null这里面呢,我测了下,输入a.txt有东西,但是输入到/dev/ null查看没东西啊

/dev/null是个黑洞,有进无出.
主要用于丢弃输出信息。

这是输出重定向,不显示标准的输出(STDOUT)和错误信息(STDERR)

/dev/null是个黑洞,扔进去什么都会不见。
所以善用/dev/null。

你就理解成dev/null 是一个垃圾场就行了,或者是一个黑洞,什么东西进去了就都没有了。。将一些没有用的输出定位到这里,就消失了。。。

/dev/null是linux下的一个比较特殊的字符设备,主要是用于丢弃输出信息,从而过滤出错误信息,有利于快速找到错误发生的原因。

要的就是这样的效果,处理错误时,来自 stderr 的输出被丢弃到文件/dev/null中。/dev/null是一个特殊的设备文件,它接收到的任何数据都会被丢弃。null设备通常也被称为黑洞,因为凡是到这儿的数据都将一去不返。

输出重定向
可以参考这篇内容http://c.biancheng.net/cpp/view/2738.html

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!