您的位置:首页 > 其它

find pwd grep cp xargs组合

2009-03-28 20:50 357 查看
[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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: