15

Per xargs --help:

-L, --max-lines=MAX-LINES use at most MAX-LINES non-blank input lines per command line

-n, --max-args=MAX-ARGS use at most MAX-ARGS arguments per command line

It is very confusing. Is there any difference between -L and -n?

ls *.h | xargs -L 1 echo 
ls *.h | xargs -n 1 echo 
camino
  • 10,085
  • 20
  • 64
  • 115

1 Answers1

16

-n splits on any whitespace, -L splits on newlines. Examples:

$ echo {1..10}
1 2 3 4 5 6 7 8 9 10
$ echo {1..10} | xargs -n 1
1
2
3
4
5
6
7
8
9
10
$ echo {1..10} | xargs -L 1
1 2 3 4 5 6 7 8 9 10
$ seq 10
1
2
3
4
5
6
7
8
9
10
$ seq 10 | xargs -n 1
1
2
3
4
5
6
7
8
9
10
$ seq 10 | xargs -L 1
1
2
3
4
5
6
7
8
9
10
Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
dosentmatter
  • 1,494
  • 1
  • 16
  • 23