Dev Null

A process has 3 standard flows:

  • 1 input (STDIN, typically the keyboard)
  • 2 outputs (STDOUT, STDERR)

These flows are referenced by the following variables: STDIN, STDOUT et STDERR which values are 0, 1 and 2

By default, “>” will only redirect the STDOUT (not the STDERR)

$ my_command > /dev/null	

If we’d like to redirect only the STDERR we would use:

$ my_command 2>/dev/null 

By using “2>&1”, we specify that we want to redirect the STDERR on the same “channel” in which we are sending the STDOUT. In that case if STDOUT is redirected to /dev/null so will STDERR.

$ my_command > /dev/null 2>&1		
comments powered by Disqus