For example, if I have a statement:
/home/1/test.sh > /home/1/test.log 2>&1
What does the last part of this do effectively?
Thanks.
For example, if I have a statement:
/home/1/test.sh > /home/1/test.log 2>&1
What does the last part of this do effectively?
Thanks.
Greater than or 1 greater than means redirect stdout (standard output, what's usually written to the terminal. 2 greater than means redirect stderr (standard error).
In 2>&1, you are redirecting stderr AND (ampersand) stdout.
2>&1
as such doesn't redirect stderr and stdout, though (that's what &>
does). It redirects stderr to wherever stdout is pointing at that moment.
– DonHolgo
Mar 12 '21 at 10:26