linux 中xargs -i 和-I在使用上的区别

 

001、 -i

[root@PC1 test]# ls
[root@PC1 test]# touch a.txt a.csv
[root@PC1 test]# ls
a.csv  a.txt
[root@PC1 test]# find ./ -name "*.txt" | xargs -i cp {} {}.bak     ## -i单独传递参数
[root@PC1 test]# ls
a.csv  a.txt  a.txt.bak

 

02、-I

[root@PC1 test]# ls
[root@PC1 test]# touch a.txt a.csv
[root@PC1 test]# ls
a.csv  a.txt
[root@PC1 test]# find ./ -name "*.txt" | xargs -I cp {} {}.bak   ## 报错
xargs: {}: No such file or directory
[root@PC1 test]# ls
a.csv  a.txt

 

-I的正确用法:

[root@PC1 test]# ls
[root@PC1 test]# touch a.txt a.csv
[root@PC1 test]# ls
a.csv  a.txt
[root@PC1 test]# find ./ -name "*.txt" | xargs -I {} cp {} {}.bak   ## 正确用法
[root@PC1 test]# ls
a.csv  a.txt  a.txt.bak

 

posted @   小鲨鱼2018  阅读(234)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2022-05-08 R语言中实现第一列转化为行名、第一行转化为列名
2022-05-08 R语言中利用readxl包读取excel数据
2022-05-08 R语言中获取变量占据内存的大小object.size函数
2022-05-08 R语言实现数据的标准化
2022-05-08 R语言中scale函数的用法
2022-05-08 数据的中心化、标准化
2022-05-08 R语言中批量加载包
点击右上角即可分享
微信分享提示