whats the diffrence between "command.sh > /dev/null 2>&1" vs "command.sh 2>&1 >/dev/null"
Solution 1:
The commands are performing two redirects:
-
> /dev/null
redirects Standard Output to/dev/null
-
2>&1
redirects Standard Error to Standard Output
As you correctly guessed, the global effect is that both Standard Output and Standard Error are redirected to /dev/null
.
The two redirects are both meant to be interpreted by the shell, not by the actual program called; thus they are appended to the end of the command line. They are logically distinct, although their effects are cumulative; thus they can be specified in any order you prefer.
TL;DR: the two commands are completely equivalent, the difference is purely cosmetical.