What is the purpose of the "/ dev / null" path in some commands?


I have often seen some people teaching to do some commands (mostly related to text outputs or things like that), where that directory or file called /dev/null is used.


  wget -qO- $url &> /dev/null
  • What is the purpose of this /dev/null ?
  • What is it? A directory or a file?
  • Why do some commands (as in the example above) use it?
asked by anonymous 17.03.2016 / 13:48

1 answer


Before the technical explanation, a metaphor. You know when you send an email to a large company complaining about a product and receive absolutely no response, this is the famous case where your email dropped in /dev/null , ie someone saw and left there (or probably did not even see ) and you ran out of your answer.

The /dev/null is a special file. You can redirect output to this device and the content is intentionally discarded. Redirection to /dev/null always reports writing success.

As said by @GuilhermeLautert in comments, /dev/null is known as Black Hole because of this.

In the context of the example of wget , /dev/null is used since it is not necessary to download content to a file, the purpose is to only make a request for a given URL. The content will obviously be transmitted from the server to the computer running wget, but as -O exists in the command, output will be redirected to /dev/null .

17.03.2016 / 14:21