The shell environment supports input/output redirection, which is represented by the & lt; and & gt; symbols. Output error information to file a. tx...
Supports input/output redirection in Linux Shell environment, with symbols <And> . 0, 1, and 2 indicate the standard input, standard output, and standard error information output, which can be used to specify the standard input or output to be redirected. for example, 2> a.txt outputs the error information to the.txt file.
At the same time, you can also implement redirection between the three standard input and output. for example, you can use 2> & 1 to redirect the error message to the standard output.
In Linux, there is also a special file/dev/null, which is like a bottomless pit, and all the information redirected to it will disappear without a trace. This is very useful. when we do not need to display all information about the program, we can redirect the output to/dev/null.
If you want to disable normal output and error information, you must redirect both standard output and standard errors to/dev/null. for example:
# Ls 1>/dev/null 2>/dev/null
Another way is to redirect errors to standard output and then to/dev/null, for example:
# Ls>/dev/null 2> & 1
Note: the order here cannot be changed. Otherwise, the desired effect cannot be reached. in this case, the standard output is redirected to/dev/null and the standard error is redirected to the standard output, since the standard output has been redirected to/dev/null, the standard error will also be redirected to/dev/null, so that everything is quiet :-)
Author westpoint_tb