51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

linux 命令 后向引用

linux 命令 后向引用

将查找到的文件 交给其他命令的3中方式

常用的命令有 cp , rm , mv

方法1: xargs

案例: 查找名字为1.txt 的文件,并且拷贝到/opt 目录

find ./  -name all.txt | xargs -i cp {} /opt

方法2: exec

find ./ -name 1.log -exec cp {}  /opt / \;

[root@baimeidashu /opt]#find ./ -name 1.txt -exec cp {} /tmp/ \;

方法3: `` 反引号 和 $()

cp `find ./ -name  1.txt ` /tmp/

[root@baimeidashu /opt]#\cp `find ./ -name 1.txt` /tmp
赞(1)
未经允许不得转载:工具盒子 » linux 命令 后向引用