find 后cp或拷贝目录结构

来源:互联网 发布:java网上订餐系统视频 编辑:程序博客网 时间:2024/06/03 18:05


find . -name '*.ctp' | xargs -i cp {}  /home/www/web/


查找当前目录下所有ctp文件并复制到/home/www/web/目录下


【转】

[linux@/etc]# find `pwd`|grep 'conf$'|xargs -i cp {}  /home

 
这条命令会复制所有/etc及其子录下的最后的文件名为conf的文件到/home/目录下
 
 
 
注意:这个命令在Red Hat 9下通过 -i的意思用man xargs得如下内容:
 --replace[=replace-str], -i[replace-str]
              Replace occurences of replace-str in the initial arguments  with
              names  read  from  standard input.  Also, unquoted blanks do not
              terminate arguments.  If replace-str is omitted, it defaults  to
              "{}" (like for `find -exec').  Implies -x and -l 1.
至于{}代表cp这个命令的第一个参数
 
[linux@/home]# pwd |xargs -i cp /etc/syslog.conf {}
上面这条命令会复制etc目录下的syslog.conf到当前目录下 {}这对括号表示的是cp的第二个参数,他的值由前面的pwd命令取得,并由xargs命令传给cp


find code-wmmp/* -type d | xargs -i install -d yy/{}
0 0