【Linux】参数传递之xargs

1.xargs命令可以使用-I选项指定一个替换字符串,xargs会用读取到的参数替换掉这个替换字符串。

:~/work/test$ ls *.txt | xargs -I{} cp {} /tmp/
:~/work/test$ ls *.txt | xargs -I{} ls {}
1.txt
2.txt
3.txt

2.xargs命令可以通过-d选项指定任意字符为分隔符,默认以空格、Tab制表符或换行符为分隔符。

:~/work/test$ echo "hellotheworld" | xargs
hellotheworld
:~/work/test$ echo "hello the world" | xargs
hello the world
:~/work/test$ echo "helloatheaworld" | xargs -da
hello the world
posted @ 2021-08-25 20:11  爱啦啦  阅读(490)  评论(0编辑  收藏  举报