问题
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
回答1:
-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
来源:https://stackoverflow.com/questions/41623959/what-is-the-difference-between-l-and-n-in-xargs