shell short question(stdout, stderr)
I know:
command >/dev/null //output not shown command 1>/dev/null //standard output not shown command 2>/dev/null //standard error not shown command 2&> /dev/null //standard output + error not shown how about: command 1>/dev/null 2>&1 it sends stdout to /dev/null and?? |
Quote:
Note that the order matters: "command 2>&1 >/dev/null" doesn't work because stderr is first redirected to the same place as stdout, after that, stdout is redirected to /dev/null. In the case of redirecting to /dev/null it does not matter much which form you use, but when you want to redirect both stdout and stderr to a single file, this doesn't work: "command >my_file.txt 2>my_file.txt" but this does: "command >my_file.txt 2>&1" These forms are exactly the same, only the syntax is different: command >some_file 2>&1 command 1>some_file 2>&1 command &> some_file command >& some_file And I suppose the one you mentioned ("command 2&> some_file") belongs to this list as well. |
Quote:
2>&1 redirects stderr to stdout, error messages get sent to the same place as standard output. this is why Code:
command 1>/dev/null 2>&1 Code:
command &>/dev/null Both redirect stderr and stdout to /dev/null |
It redirects stderr to stdout which is redirected to /dev/null. The effect is the same as
2&>/dev/null. |
Quote:
I said by mistake: "standard input(stdin)", where it should have been: "standard output (stdout). Thanks for correcting that. |
All times are GMT -5. The time now is 11:21 PM. |