Shell-redirection explanation

Source: Internet
Author: User

Standard Input
The standard input is the file descriptor 0. It is the command input. The default input is the keyboard, or file or other command output.

Standard output
The standard output is the file descriptor. 1. It is the command output. The default output is the screen or file.

Standard Error
The standard error is file descriptor 2. It is the output of the command error bit rate. The default value is the screen. It can also be a file.

Redirect operator description
> Write command output to a file or device (such as a printer) instead of a command prompt window or handle.

<READ command input from a file instead of a keyboard or handle.

> Add the command output to the end of the file without deleting the existing information in the file.

> & Write the output of one handle to the input of another handle.

<& Read the input from one handle and write it into another handle output.

| Read the output from one command and write it into the input of another command. It is also called an MPS queue.

Common File redirection command shell code

  1. Command> filename redirects the standard output to a new file
  2. Command> filename redirects the standard output to a file (append)
  3. Command 1> fielname redirects standard output to a file
  4. Command> filename 2> & 1 redirects the standard output and standard error to a file.
  5. Command 2> filename redirects a standard error to a file
  6. Command 2> filename redirects the standard output to a file (append)
  7. Command> filename 2> & 1 redirects the standard output and standard error to a file (append)
  8. Command <FILENAME> filename2 uses the command as the standard input in the filename file and the filename file as the standard output.
  9. Command <FILENAME: The command is input using the filename file as the standard.
  10. Command <delimiter reads data from standard input until the division of d e l I t e r is met
  11. Command <& M uses the file descriptor m as the standard input
  12. Command> & M redirects standard output to file descriptor m

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.