Skip to main content
added 6 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

By default, xargs will pass as many parameters on a single command line as it can - usually up to the shell limit of (IIRC) 256 characters. So the command you're using, ls | xargs wc -l, is functionally equal to wc -l *. The behavior I believe you're expecting is for xargs to run wc once for each file, which can be produced by adding the -n option, ls | xargs -n 1 wc -l.

By default, xargs will pass as many parameters on a single command line as it can - usually up to the shell limit of (IIRC) 256 characters. So the command you're using, ls | wc -l, is functionally equal to wc -l *. The behavior I believe you're expecting is for xargs to run wc once for each file, which can be produced by adding the -n option, ls | xargs -n 1 wc -l.

By default, xargs will pass as many parameters on a single command line as it can - usually up to the shell limit of (IIRC) 256 characters. So the command you're using, ls | xargs wc -l, is functionally equal to wc -l *. The behavior I believe you're expecting is for xargs to run wc once for each file, which can be produced by adding the -n option, ls | xargs -n 1 wc -l.

Source Link
John
  • 17.4k
  • 2
  • 36
  • 44

By default, xargs will pass as many parameters on a single command line as it can - usually up to the shell limit of (IIRC) 256 characters. So the command you're using, ls | wc -l, is functionally equal to wc -l *. The behavior I believe you're expecting is for xargs to run wc once for each file, which can be produced by adding the -n option, ls | xargs -n 1 wc -l.