bash - In the shell, what does " 2>&1 " mean? -
In a Unix shell, if I want to add stderr and stdout stdout stream for further manipulation, I can add the following at the end of my order:
2> & Amp; 1 So, if I want to use "head" on the output from G ++, then I can do something like this:
++ lots_of_errors 2 & gt; And 1. Head So I can only see some errors first
I always have trouble remembering it, and I have to constantly watch it, and this main This is because I am unable to fully understand the syntax of this particular move. Can someone break it and describe the character that "2> and 1" mean?
The file descriptor is 1 standard output (stdout).
File descriptor 2 is the standard error (stderr).
One way to memorize this creation is this (though it is not entirely accurate): First, 2 & gt; 1 can be a good way to redirect stderr to stdout. However, it will actually be interpreted as "redirecting to stderr in a file called" code <1> . & amp; This indicates what happens according to a file descriptor and no file name is created: 2> & Amp; 1 .
Comments
Post a Comment