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
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
> /dev/null 2>&1
&> also combines stdout and stderr
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
6 months ago