always do not understand, the pipeline is the result of the previous command as a parameter to the next command, that in | After the addition of Xargs there is no difference
Newuserff wrote:
Lazy snail Gentoo wrote:
The pipeline is to implement "standard input for the previous standard output as a later"
Xargs is a parameter that implements "standard input as a command"
You can try running:
Code:
echo "--help" |cat
echo "--help" |xargs Cat
Look at the difference in the results.
Tried, still not very sure to understand what the meaning of the end, and then explore to see the
If you enter cat directly on the command line without entering anything else, then cat will wait for standard input, so you can
With keyboard input and press ENTER to let cat read the input, CAT returns as is. And if you enter--help, then the cat program will be on the standard output
Print your own Help document. In other words, the pipe character | The arguments passed to the program are not the parameters that you simply enter after the program name, and they are
The read function inside the program such as scanf and get receive, while Xargs is the content as a normal parameter passed to the program, equivalent to your handwriting
Cat--help
From: http://forum.ubuntu.org.cn/viewtopic.php?t=354669
Additional explanations:
There are three files in a directory
A.C B.C C.C
Find. /-print command will print out three filenames
Find. /-print | grep A.C will only print out A.C this file
If you only enter the command grep A.C
Then you only enter the A.C string in the keyboard, A.C will be printed two times, or only the characters you entered
If you are looking for three files, the file includes a Hello character
Find./-print | Xargs grep Hello
Summary: The pipe after the Xargs equivalent to the Xargs after the command return to perform a bit and then input from the keyboard
The result content of the preceding command executed by the pipe character
Plus Xargs is equivalent to directly from the keyboard input pipe character in front of the results of the command execution and then enter
To sum up, the order of carriage return is not quite the same.
(reprint) The difference between a pipe command and a Xargs (classic explanation)