Shell---Data flow redirection

Source: Internet
Author: User

Data Flow redirection: is a command that should appear on the screen after the data transfer to other places.

Standard input (stdin): code 0, using < or <<;

Standard output (STDOUT): Code 1, using > or >>;

Standard error Output (STDERR): Code 2, using 2> or 2>>

One: Standard output

>:1 file does not exist will be automatically created

2 file exists, empty the file first, then write the data to

3 If the content already exists in the file, overwrite the contents of the file (if you do not want to overwrite it, use >> append to the original text)

Two: standard error output

2>: Output the wrong data to a specified file or device in an overridden manner

2>>: The incorrect data is output to the specified file or device in an additive way

>list_right 2>list_error

Attention:

1:/dev/null Garbage bin Black hole

How to filter out error messages and output the correct information??

#find/home-name. BASHRC  2>/dev/null

2: How to write the correct error message to the same file??

#find/home-name  >list   2>&1/home-name &> List 

Both of these methods can be

Three: Standard input

The simplest way to do this is to change the way the keyboard input is used instead of the file content.

Cat >   a   <    /root/b

Writes the contents of B to a

Shell---Data flow redirection

Related Article

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.