Linux Learning Pipeline and IO redirection

Source: Internet
Author: User
Tags stdin

1. I/O redirection: Modify the default input and output devices

stdout/output Redirection, code 0: Change the sent data channel (STDOUT) to output to the specified file

: Saves the output to the specified file by overwriting, such as saving the results of the LS/command execution in the files file:

LS/> file


>>: Saves the input as an append in the specified file, for example in the original file to have some content, but instead writes with >> append

stdin/input redirection, code 1: Change the read-in data channel (stdin), refers to read from the specified file

<: Reads data from the specified file

<<:here document, and also means to establish documentation here

stderr/standard error output, code 2: When we execute the command may cause the command to fail because of the command write error or other problem, when the output is wrong input, naturally cannot be redirected with standard output

2>: Saves the wrong information in the specified file in the Overwrite mode

2>>: Save the wrong information in the specified file in append mode

It is important to note that the correct input information and error output information are output, but not the same mechanism, because the execution status of the Linux command results in a 0-type representation of the correct execution, 1 for the error, and 2 for the error

Use &> or 2>&1 to save standard output and standard error output in the same file

/dev/null is a data black hole, we can export useless information, not want output information together to this directory

2, | Pipe: The result of the previous command as input to the next command

Cat Inittab | Wc-l

Using cat to view inittab content to the WC to count the total number of rows, the pipeline can use more than one, the result of the first command as the input of the second, the result of the second article as the input of the third, and so on


This article is from the "Pole Men" blog, please be sure to keep this source http://wtime.blog.51cto.com/8829658/1530604

Linux Learning Pipeline and IO 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.