xargs


[root@localhost ~]# ll /var/log/yum.log

-rw------- 1 root root 2446 12月 21 14:45 /var/log/yum.log

[root@localhost ~]# find /var/log/yum.log | xargs -i cp {} {}.bak

[root@localhost ~]# ll /var/log/yum.log.bak

-rw------- 1 root root 2446 12月 21 15:07 /var/log/yum.log.bak

[root@localhost ~]# find /var/log/yum.log.bak | xargs -i rm -rf {}

[root@localhost ~]# ll /var/log/yum.log.bak

ls: 无法访问/var/log/yum.log.bak: 没有那个文件或目录


exec


[root@localhost ~]# ll /var/log/yum.log

-rw------- 1 root root 2446 12月 21 14:45 /var/log/yum.log

[root@localhost ~]# find /var/log/yum.log -exec cp {} {}.bak \;

[root@localhost ~]# ll /var/log/yum.log.bak

-rw------- 1 root root 2446 12月 21 15:05 /var/log/yum.log.bak

[root@localhost ~]# find /var/log/yum.log.bak -exec rm -rf {} \;

[root@localhost ~]# ll /var/log/yum.log.bak

ls: 无法访问/var/log/yum.log.bak: 没有那个文件或目录