Sometimes I want to get the output of a Write statement when writing some shell scripts. For example, when I use javac to compile a java class, I want to know whether the compilation is successful, it is easy to think of to judge based on the javac output result. Both the output and error messages are displayed on the terminal, but if we directly use javac Main. java | wc-l to judge (Main. java syntax errors). The final result is an error output, and the number of rows is counted as 0. In this case, we only need to redirect the error to the standard output, because wc and other commands only obtain the standard output stream through the pipeline. The correct syntax is as follows: javac Main. java 2> & 1 | wc-l. Linux stream definition: 0 standard input, 1 standard output, 2 standard error. 2> & 1 point the standard error stream to the standard output stream, so that we can determine the execution of the command based on the number of wrong lines or other information.