The difference between Xargs and pipelines under Linux

Source: Internet
Author: User
The pipeline takes the previous standard output as the following standard input, and xargs the standard input as the parameter of the command

You can try running the following code:

echo "--help" |cat
echo "--help" |xargs Cat

The results are as follows:

If you enter cat directly on the command line and do not enter a command parameter, then cat waits for standard input, you enter content through the keyboard and press ENTER, and the cat process reads the input and returns it as it is.

So if you enter--help at this point, then the cat program will output on the standard output--help

Other words

  • Pipe symbol | What is passed to the program is not the parameters that you simply enter after the program name, and they are received by the program's internal read function such as scanf and get.
  • Xargs is to pass the content as a normal parameter to the program, in this case the equivalent of you hand-written cat--help, the system will output the cat's Help document

From: http://forum.ubuntu.org.cn/viewtopic.php?t=354669

The difference between Xargs and pipelines under Linux

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.