Data Stream redirection

Source: Internet
Author: User

Data Stream redirection

OUTPUT

> Output the correct data to the specified file or device in overwrite mode.

> Outputs the correct data to the specified file or device in an accumulative manner.

2> overwrite the error data to the specified file or device.

2> output error data to a specified file or device in the accumulative manner

Eg: ls-l> ~ /LsResu.txt

Ls-l/etc/123 2> ~ /LsResu.txt

Ls-l/etc/123> ~ /LsRightResu.txt 2> ~ /LsErrorResu.txt

What if I want to output correct and wrong data to the same file? Pai_^

Ls-l/etc/123> ~ /LsResu.txt 2> & 1

Ls-l/etc/123 &> ~ /LsResu.txt

What if I don't want to display the error message?

Ls-l/etc/123 2>/dev/null

INPUT

<The data is replaced by the file content (^ + D is required to end the input)

<End input with a string

Eg: cat> testDoc.txt <~ /. Bashrc

Cat> testDoc.txt <END

ELSE

What if you want to automatically execute the next command after executing a command?

Eg: ls-l; date

Judgment basis

& Execute from left to right, end when there is a mistake

| Execute from left to right. If there is a positive result, it ends (or ends naturally)

Eg: mkdir/etc/123 & ls-l/etc/123

Ls-l/etc/123 2>/dev/null | (mkdir/etc/123 & ls-l/etc/123) // If/etc/123 exists, the result is output. If not, the result is created and output. If an error occurs during creation, the result is not output.

 

Ps: After finishing the sorting, I really had a lot of GAINS.

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.