Shell input and output redirection

Source: Internet
Author: User

Standard input: 0 <, << or 0< 0<<

Standard output: 1 >,>> or 1>,1>>

Error Output: 2 2>>,2>

/dev/null 这个设备,是linux 中黑洞设备,什么信息只要输出给这个设备,都会给吃掉 Send standard output, error output to/dev/null $ ls test .sh test1.sh > /dev/null 2>&1&AMP;,&AMP;1 represents the standard output &AMP;2 represents the error output

The//Error output is written directly in the standard output, which is displayed on the terminal screen.

: ~$ Ls-yz 2>&1
Ls:invalid option--' Y '
Try ' ls--help ' for more information.

The error output is output to the standard output, which is displayed on the screen and not written in the fname file.
: ~$ Ls-yz 2>&1 1>fname
Ls:invalid option--' Y '
Try ' ls--help ' for more information.
: ~$ ls
Androidstudioprojects Desktop Documents Downloads examples.desktop fname Music Pictures public Templates USR Videos work
: ~$ Cat FName

The// standard output is written in the fname file, and the error output is output to the standard output, which is the file fname.
: ~$ Ls-yz 1>fname 2>&1
: ~$ ls
Androidstudioprojects Desktop Documents Downloads examples.desktop fname Music Pictures public Templates USR Videos work
: ~$ Cat FName
Ls:invalid option--' Y '
Try ' ls--help ' for more information.

Shell input and output 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.