pipe and xargs

tags: learning linux diff-between

content

  • pipe | directs the output of a command to the input of another command
    • output is treated as a whole, like cmd1 > file then cmd2 < file
  • xargs uses the output of the previous command as input arguments to another command
    • output is separated by , \n or \null, then input to another command
    • like cmd1 > file, for line in file: cmd2 line

compare:

  • find . -name "*.txt" | wc -l
  • find . -name "*.txt" | xargs wc -l

up

down

reference