Linux Data stream redirection

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.