Common commands in Linux pipe

Source: Internet
Author: User

Most Linux commands output to standard output after processing the data, but if the data goes through the series of steps to be processed, it is the number of data needed, which needs to be piped to help complete.

The pipe command uses the ' | ' As a delimiter, the execution result of the command before the qualifier is processed as input to the command after the delimiter. The execution mode here is not the same as the "Sequential Execution command". Pipeline commands not only emphasize the dependencies of the pre-and post-command, but also have a very important limitation:
the execution result of the pre-delimiter command must be output to standard output, and the command after the qualifier must be able to receive the standard input as the processing data .

Here are a few examples to familiarize yourself with the pipeline command:

    1. There are many files in the/etc directory, usually directly LS view, the screen can not display all, this is the use of Pipeline command:
ls -al /etc | less

The LS command outputs the file details from the directory to standard output, and less can accept standard input as processing data. This will reuse the ability to view the less command before and after, or even retrieve the ability to help us effectively view the required files.

    1. See how many recent users have logged in often using the last command, but will output very much information if you want to filter to view only users:
last | cut -d ‘ ‘ -f 1

Last the recent login information is output to the standard output, cut accepts the standard input as a parameter, processing, and then output to the standard output for display.

Core points of using pipeline commands

    • The command before the pipe command can only handle the standard output, no processing capability for standard error output;
    • The command after the pipeline command must be able to accept data from the previous command as standard input to continue processing;

The data from stdin must not be accepted by commands such as LS and CP. Tail, head, less, more and so on can accept the standard input.

Common commands in Linux pipe

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.