Shell Command: ls-Al> out. log 2> & 1
Command Description: redirects the 1 (stdout) Output and 2 (stderr) output of the shell command to the out. log file.
Explanation: ls-al. After a commond statement is executed, there are two types of output: 1 (stdout) Output and 2 (stderr). By default, 1 is redirected to the standard output screen.
Ls-Al> out. log, which redirects the default output (which is actually output to the stdout on the screen) to the out. log file.
2> & 1 redirection means that & 1 means to get the standard output of 1 (stout), which is to redirect 2 to 1, because the current 1 has been redirected to the screen (the screen has been redirected to the out. so stdout and stderr are redirected to the out. log File.
Meanings of other writing methods:
Ls-Al> out. log 2> 1: The default 1 (stdout) is redirected to out. log, and 2 (stderr) is redirected to file 1.
ls 2> 1. If you test the file, no error is reported, but an empty file 1 is output.
ls XXX 2> 1 test, if the file XXX does not exist, the error is output to 1.
ls XXX 2> & 1 test. The file 1 is not generated, but the error is returned to the standard output;
ls XXX> out.txt 2> & 1, which can be replaced by ls xxx 1> out.txt 2> & 1; redirection symbol> errors are 1, errors, and outputs are all transmitted to out.txt.