Redirect simple application (enable and disable redirection)

Source: Internet
Author: User
The simple application of redirection (enable and disable redirection) is a simple example. today, you need to output errors to files and other normal data to the screen, LOG can be implemented in this way. /test. logexec3 & gt; & amp; 14 & gt; & amp; 22 & gt; $ LOG1 & gt; $ LOGechoaa... the simple application of redirection (enable and disable redirection) is a simple example. today, you need to output errors to files and other normal data to the screen, LOG =. /test. logexec 3> & 1 4> & 22> $ LOG 1 >>$ LOGecho aaaexec 1> & 3 2> & 4 echo bbb memory method: I also thought it would be meaningless to output 3 to the standard output. In fact, you need to understand this, that is, file descriptor 3 is assigned as a standard output. here we can experiment like this: LOG =. /test. logexec 3> & 1 4> & 2 2> $ LOG 1> $ LOGecho aaaecho ccc> & 3 exec 1> & 3 2> & 4 echo bbb, you can see that ccc is normal output, therefore, when executing exec 1> & 32> & 4, it can be understood that file descriptor 1 is replaced by file descriptor 3, thus enabling or disabling redirection in a script.
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.