shell /dev/null mask standard, error output

/dev/null
represents an empty device. If the log is recorded to an empty device, no log is recorded.
Null devices are a common means of processing information that does not require output.

 

 

Example of use

 

1. Shield standard output
root@bosh :# cat a.txt
9999999999999999999999999999999
root@bosh :# cat a.txt > /dev/null
root@bosh :# cat a.txt 1> /dev/null
root@bosh :#

 

2. Shield error output
root@bosh :# cat b.txt
cat: b.txt: No such file or directory
root@bosh :# cat b.txt 2> /dev/null
root@bosh :#


3. Can be used to clear file content
root@bosh :# cat a.txt
9999999999999999999
root@bosh :# cat /dev/null > a.txt
root@bosh :# cat a.txt
root@bosh :#

 

Easier way to clear file contents
root@bosh :# cat a.txt
999999999999999999999999
root@bosh :# >a.txt
root@bosh :# cat a.txt
root@bosh :#

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326926483&siteId=291194637