Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I understand that the standard to redirect to is /dev/null, but why not use /dev/zero? Does it not have the same effect?

Another question, what do all the 1>> 2>> &>> >>& and whatnot mean for redirection

share|improve this question

Using /dev/zero has the same effect as /dev/null when redirecting output to it. There is no reason not to use it. The latter is just more commonly found in examples and thus has become more popular.

As for redirection, you should check your shell's manual. The Bash Hackers wiki has a tutorial on redirection and another reference page.


  • > redirects output to a file

  • >> when redirecting appends to a file (or creates it when it doesn't exist), whereas > truncates and therefore deletes file contents

  • n>, where n is the number of the file descriptor, redirects output of that descriptor to a file. Typically 1 and 2 are used, being stdout and stderr, respectively.

  • m>&n redirects file descriptor m's output to n, so you could combine, for example, stdout and stderr: > /dev/null 2>&1

  • &> also combines stdout and stderr

share|improve this answer
Well, there is a difference. If you are redirecting the input, /dev/null gives nothing, whereas /dev/zero gives zeros. – YtvwlD Jun 16 '14 at 9:59
@YtvwlD That's why I said, "when redirecting output to it". Of course they have different uses for input. – slhck Jun 16 '14 at 10:47
Does >&- /really/ have the same effect as > /dev/null? Perhaps I'm being too pedantic here, but from where I'm sitting they look quite different. – Robbie Mckennie Jun 17 '14 at 8:22
@RobbieMckennie You're right, it doesn't work apparently. I took that info from the Wiki but didn't check at the time. – slhck Jun 17 '14 at 8:33
fyi: "All write operations to /dev/zero succeed with no other effects" – akira Jun 18 '14 at 9:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .