我尝试过cat /dev/zero
,但似乎没有任何作用。我用谷歌搜索/dev/zero
,它说它基本上是一个无限大小的空白文件。是否cat
打印无限数量的不存在的字符?这是如何运作的?如果它是 0 字节,它如何提供无限数据?如果可以简单地创建一个空白文件,该文件有什么用途?
根据FHS
关于/dev
:
它包含了:
The following devices must exist under /dev.
/dev/null
All data written to this device is discarded. A read from this device will return an EOF condition.
/dev/zero
This device is a source of zeroed out data. All data written to this device is discarded. A read from this device will return as many bytes containing the value zero as was requested.
...
Run Code Online (Sandbox Code Playgroud)
观察两者都有:
All data written to this device is discarded …
Run Code Online (Sandbox Code Playgroud)