linux find查找并拷贝 exec xargs区别

-exec
    1.参数是一个一个传递的,传递一个参数执行一次rm
    2.文件名有空格等特殊字符也能处理
-xargs 
    1.一次将参数传给命令,可以使用-n控制参数个数
    2.处理特殊文件名需要采用如下方式:
    find . -name "*.txt" print0 |xargs -0 rm {} 

find /opt/test/ -type f -name "*.txt" -exec cp {} /tmp \;

find /opt/test/ -type f -name "*.txt" | xargs -i cp {} /tmp

posted @ 2017-02-10 11:55  howhy  阅读(3942)  评论(0编辑  收藏  举报