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