Linux Data redirection

Source: Internet
Author: User

    1. Standard input (stdin): code 0, using < or <<;
    2. Standard output (STDOUT): Code 1, using > or >>;
    3. Standard wrong Output (stderr): Code 2, using 2> or 2>>;

    • 1>: The "Correct information" is added to the specified file or device in a covered manner;
    • 1>>: The "Correct information" is added to the specified file or device in a cumulative way;
    • 2>: To cover the method of "wrong information" to the designated files or devices;
    • 2>>: The "wrong information" is added to the specified file or device in a cumulative way;

According to Bird Brother's information, simple record a few small examples:

Example two: Using General identity account Search/su -dmtsai  <==find /home-name. BASHRC <== Identity is Dmtsai Oh!  Find:/home/lost+found:permission denied  <== standard errorfind:/home/alex: Permission denied        <== standard errorfind:/home/arod:permission denied        <== Standard error/HOME/DMTSAI/.BASHRC                       <== standard output

Find 2> List_error

Find 2>/dev/null/HOME/DMTSAI/.BASHRC  <== only stdout will be shown on the screen, stderr is discarded

Find 2> List  <==find2>&1     <==Find /home-name. BASHRC &> list         <== is correct

The first line of the above table is wrong because the two shares are written in a file at the same time, and no special language is used, and the two pieces of information may cross-write into the file, causing the order to go wrong. So although the final list file is still going to be produced, the information in the arrangement will be weird, not the output sort on the original screen. To write the special language of the same file as shown in the table above, you can use the 2>&1 or &>! In general, birds are more accustomed to using 2>&1 's language Method!

Original address: Http://linux.vbird.org/linux_basic/0320bash.php#redirect

Data redirection for Linux

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.