【Linux】参数传递之xargs

时间:2021-08-25 23:31:09   收藏:0   阅读:20

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

原文:https://www.cnblogs.com/wucaiyun1/p/15186763.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!