1. Standard inputs and outputs
Executes a command, has input, has output. Standard input: Standardized input, check for stdin, code 0, use < or << standard output: Standardized outputs, abbreviation: stdout. Command execution returns the correct result, code 1, using > or >> standard error output; Standard error output. Abbreviation: stderr, the command executes the returned error message. The code is 2, which is output to the screen using > or >> by default.
2. Data Flow output redirection
The output defaults to the screen, and you can redirect the output to a file or other device. Use > or >>>: To overwrite write >>: to append to the end of the original file, to create a file if the original file is empty.
$ find/home-name. BASHRC Find:/home/lost+found:permission denied //STDERR/HOME/USER/.BASHRC //stdout
Use > to redirect content to a file
$ find/home-name. BASHRC > Std_out 2> std_err
Writes a query result to a Std_out file writes a standard error to the Std_err file note that there can be no spaces in the middle of:2> or 2>>.
The/dev/null directory represents an empty device, and the content written here is discarded. If you do not want to save the error message, you can write/dev/null
$ find/home-name. BASHRC > Std 2>/dev/null
Want to put the correct and wrong write to a file using 2>&1 or &>
$ find/home-name. BASHRC > Std_out 2>&1$ find/home-name. BASHRC
The general recommendation is to use the first notation.
3. Input redirection
stdin for keyboard input, use cat
< to change keyboard input to file content input
[[email protected] sh]$ cat > Catfile < Pass
<< indicates the end input.
[[email protected] sh]$ cat > Catfile << "EOF" > Hello,> this was from Cat > Eof[[email protected] sh]$ CA T Catfile Hello,this is from cat [[email protected] sh]$
When the keyboard input EOF ends the input without having to enter Ctrl+d.
Address: http://blog.csdn.net/yonggang7/article/details/40956095
Linux Data stream redirection