what is the difference between -L and -n in xargs

久未见 提交于 2021-02-07 05:59:13

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!