Linux Input/output redirection and pipelines

Source: Internet
Author: User
Redirection 11, correct content redirection symbol & gt; output redirection to a file or device overwrite the original file & gt ;! The output is redirected to a file or device to forcibly overwrite the original file & gt;

Redirection

1.1. the redirection symbol of the correct content

> The output is redirected to a file or device to overwrite the original file.

>! The output is redirected to a file or device to forcibly overwrite the original file.
> The output is redirected to a file or device to append the original file.
<Redirect input to a program

1.2, standard error redirection symbol
2> redirect a standard error output to a file or device to overwrite the original file B-shell
2> redirect a standard error output to a file or device and append it to the original file.
2> & 1 redirect a standard error output to the standard output. note: 1 may represent the standard output.
> & Redirect a standard error output to a file or device to overwrite the original file c-shell
| & Deliver a standard error pipeline to another command as input

1.3, &> correct and wrong redirection symbols

 

Resolution: upload the information in the pythfile to the temp.txt file in the user's current directory.

However, this file does not exist. Therefore, the information entered in the temp.txt file is No such file or directory.

Resolution: upload the information in the pythonfile to the temp.txt file in the user's current directory. There is a python directory under the current user directory,

Therefore, the information entered in the temp.txt file is the information of the files contained in this directory.

Note:> The redirection will clear the input file.

MPs queue

Pipeline symbol |

Purpose: based on the previous command, submit it to the next command for further processing (the output of the previous command is used as the input of the subsequent command)

Resolution:

The ll command is short for ls-l (view file attributes and other details );

The grep command is a regular expression;

The wc command is used to count the number of lines, words, and bytes in a specified file;

Tee command to read standard input data and output the content into a file;

Compile the file information in the pythondirectory. use the regular expression to write the information to the temp.txt file, and then count the number of lines, words, and bytes of the file.

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.