Hacker News new | ask | show | jobs
by ori_b 5067 days ago
Because of this:

     Any arguments specified on the command line are given
     to utility upon each invocation, followed by some
     number of the arguments read from the standard input
     of xargs.  The utility is repeatedly executed
     until standard input is exhausted.
In other words, if the argument list is too long, xargs will chunk the input and call the program repeatedly. This means that on very large projects, 'wc -l' will be called several times on subsets of the files, and you will get an incorrect total listed at the bottom.

putting a 'cat' in between fixes that. 'cat a b; cat c d' is equivalent to 'cat a b c d', so the chunking doesn't matter. And wc -l can just read from stdin without worrying about how many files there are.