/ Dev / null and / dev / zero effect

Often see the dd command to use / dev / zero file, summarize here what / dev / null and / dev / zero role and use cases.

In Unix-like systems (including Linux) in,
/ dev / null is an empty device, also called a bit bucket (bit bucket) or a Black Hole (black hole). You can enter any data to it, but any write its data will be discarded. Generally unnecessary for outputting a stream processing. (Of course, it can also be used as an input air stream)

/ Dev / zero device that provides endless null characters (ASCII NUL, 0x00), you can use any number you need. It is typically used to write the string 0 or file device, for storing initialization data. (Of course, also be used as a container for receiving the output stream), which is a typical use of the character stream to cover the information it provides, the other common use is to produce a specific size of a blank document.

Example two below:
dd = IF / dev / ZERO of = ~ / test.txt COUNT = 1K. 1 = BS
generated 1KB size of the file ~ / text.txt

the Find / -name access_log 2> / dev / null
the Find command to find a file named access_log in the / directory, and will not be displayed error output (file descriptor 2 is redirected to / dev / null).

Published 136 original articles · won praise 38 · views 260 000 +

Guess you like

Origin blog.csdn.net/Pipcie/article/details/105019923