1. Standard output: Code is 1, use > and >>, the former is overlay, the latter is append.
xxx > Aaa.txt
XXX >> Aaa.txt
2, for the wrong data, you need to use standard error output, standard error output: Code is 2, using 2> and 2>>
3, normal information and error message output to a different file, as follows:
XXX >info.txt 2>err.txt
4, normal information and error information output to the same file,
XXX >info.txt 2>info.txt is the wrong wording, info.txt content will be confused. The correct wording is:
XXX >info.txt 2>&1
5, if the information do not want to display and do not want to store it, such as the history of operations, for security, do not want to store. What to do?
Using black hole devices, xxx >/dev/null 2>&1
6, the standard input, the code is 0, use < and <<, solve the problem will originally need to keyboard output data, changed from the file read.
7, Cat >tmp.txt from the keyboard input data to tmp.txt,ctrl+d end input. If read from another file, yes: Cat >tmp.txt <aaa.txt.
8. Standard input,<< indicates that an input is encountered and an end is entered. As follows:
[[email protected] home]# cat >tmp.txt << ' 0 '
> AAA
> BBB
> 0
[Email protected] home]#
After entering 0, press ENTER to end the input and no ctrl+d to exit the input.
Linux Data stream Redirection