1. REDIRECT standard output (stdout) and standard error output (STDERR) to two different files respectively
where the symbol ' > ' defaults to the standard output redirection, meaning and ' 1> ' the same, ' 2> ' indicates a redirect standard error output, the numbers 1 and 2 are actually file descriptors, the default 1 for Linux is standard output stdout,2 for standard error output stderr
2, the standard output and the standard error output redirected to the same file, there are three kinds of writing, the latter two can be considered as the symbol & as a special mark, the first one can be regarded as the stdout output to the both file, "2>&1" You can interpret 1 as a standard output redirected file, and then add the standard error output to the end of the file
3. The redirect ' > ' defaults to emptying the destination file (if one exists) and then adding the redirected content. If you need to add at the end of the destination file, you need to use the ">>" redirection, as shown below
4,/dev/null is a special device in the Unix/linux system, it is not a real device, all the data you think is useless can be redirected to it, and will not occupy any disk space, such as the error message thrown into the/dev/null
5, the output of multiple commands are redirected to the same file in the following two ways, but based on the principle is completely different, the curly braces are actually just the output of the command in parentheses to redirect only, but the general parentheses in the command is in the child shell, that is, Subshell run. At this point we will find that because the CD instruction exists, we are still in the previous directory after the first command is run (because the location change in Subshell is not related to the parent shell), but after the second instruction is run, we are in the parent directory.
6, the output of one program as the input of another program, the most common as shown, but it is important to note that the two programs are running in different Subshell!
7. Back up the data stream in the pipeline: using the tee command as shown below, it will input the amount of data into the next-level pipeline and back them up to the Tee.file file
Shell script standard Output