IO redirect,

Source: Internet
Author: User

IO redirect,

In OS, each number in 0-9 represents a stream.

Three have been specified: [0: standard input stream], [1: Standard output stream], and [2: Error output stream]. The remaining are not yet specified.

Basic IO operations

Cmd> file redirects stdout to the file; cmd> file redirects stdout to the file (append); cmd 2> file redirects stderr to the file; cmd 2> file redirects stderr to the file (append); cat <> file opens file in read/write mode; cmd <file cmd command uses file as stdin; cmd <delimiter, read from stdin until the delimiter is encountered. Advanced IO & Operation on FD (File Descriptor)> & N copy the file descriptor
<& N the standard input is copied from the file descriptor n; <&-Disable the standard input (keyboard);> &-Disable the standard output; n <&-indicates that the n number is disabled; n> &-indicates that output n is disabled;

Cmd 2> & 1 is to copy the FD of the standard output stream to the error output, which is equivalent to: FD2 = FD1. The result is that the error output is redirected to the standard output.

Therefore:

Cmd> file 2> & 1 is to redirect the standard output to file (overwrite mode), and then put the error output content in the standard output, the final result is that the error output is redirected to the file.

Cmd> file 2> & 1 is to redirect the standard output to file (append mode), and then put the error output content in the standard output, the final result is that the error output is redirected to the file.

 

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.