Home>Article>Operation and Maintenance> What is linux standard error?
Output includes two types: one is the running result of the program (standard output), and the other is status and error information (standard error). The following article will introduce it to you. Friends in need can refer to it. I hope it will be helpful to everyone.
Standard output (standard output) and standard error (standard error) are connected to the screen by default;
Standard input (standard input) is connected by default to the keyboard;
You can use IO redirection (redirection) to change the sending location of input and output;
1. Standard output
Standard output Redirect, use the redirection operator (">") to output the program to a file, the default is to rewrite from the file header;
You can use "> test.txt" to clear the text Information;
Use ">>" to add the file to the end of the text;
2. Standard error
Standard error redirection, Use "2>" for output. Since the file stream contains three types, namely "input, output, error", corresponding to "0, 1, 2";
is ">", which is equal to "1> ;", standard output;
Handle unwanted error output, use "2> /dev/null" to hide the error message of a command.
Display output and errors at the same time. Standard error is generated after standard output, that is, use ">" first, then "2>&1", command: "xxxx > xxxx 2>&1";
You can also use "&>" to directly output standard output and error, command: "xxxx &> xxxx", provided by newer versions of bash.
As shown:
3. Standard input:
cat command (ConcATenate), the original intention is to link File, cat xxxx[1] xxxx ... > xxxx[end];
If only the first parameter is used, that is, the information is output to the screen, a short file can be output , no line breaks;
If only cat is used, information is obtained from the keyboard and output to the screen;
If only the last parameter is used , that is, cat >
"
The above is the detailed content of What is linux standard error?. For more information, please follow other related articles on the PHP Chinese website!