linux-standard input Standard output

Source: Internet
Author: User

Standard input (code 0) standard output (code 1) standard error output (code 2)

REDIRECT standard output to a file

Find/etc-name FileA >list equivalent to Find/etc-name FileA 1>list, the default > is the standard output, can write can not write, the following example is the same

redirect standard errors to a file

Find/etc-name FileA 2>list

REDIRECT standard output and standard error of a string of commands to a different file

Cat/etc/crontab/etc/filenotexist 1>stdout.txt 2>stderr.txt

REDIRECT standard output and standard errors of a sequence of commands to the same file

Cat/etc/crontab/etc/filenotexist 1>stdout.txt 2>stderr.txt

REDIRECT standard output and standard errors to the same file

Cat/etc/crontab/etc/filenotexist St.txt 2>&1

Cat/etc/crontab/etc/filenotexist &> St.txt

cat/etc/crontab/etc/filenotexist >st.txt 2>st.txt( so write is not allowed!!!) )

Standard input < and <<

< delegate reads from other files

Cat >testfile < ~/.BASHRC this statement, Cat > Testfile is a new file testfile, and waits for standard input, if it's just cat >testfile, Then after entering this command, the console will wait for keyboard input and use Ctrl+d to end the input after the input is finished. This saves the content you just entered into the testfile. The addition of < ~/.BASHRC represents the standard input to a file, and the result is the equivalent of copying a. bashrc file.

Cat >testfile << "EOF"

The function of << is equivalent to defining an end symbol, and when we enter EOF and enter it, the input ends and the content is saved to testfile.

linux-standard input Standard output

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.