proxy代理   soft软件   IT 业界特快   norton 诺顿病毒库   代理列表   search FTP搜索   whois IP地理位置   blog 追求完美  
money理财   life生活   RSS聚合门户   firefox WEB浏览器   免费域名   typeset 假古文   AntiVirus 反病毒   ipcn 站点导航  

« rsync 单模块认证配置 /etc/rsyncd.conf | Main | ICP 终于批下来了 »

July 13, 2005

find 和 exec xargs

版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明。
https://windtear.net/archives/2005/07/13/000716.html http://windtear.net/archives/2005/07/13/000716.html



find ./ -type d -mtime +5 -maxdepth 1 -exec rm -rf {} \;
find ./ -type f -ctime +30 | xargs rm -f

由于 exec 能接受的长度有些系统会有限制
所以 xargs 就有了其伟大价值

xargs 接到参数就开始处理 而不是像 exec 那样土鳖 非要接受到全部

所以呢
大家尽量 xargs 吧


NAME
       find - search for files in a directory hierarchy

SYNOPSIS
       find [path...] [expression]

   ACTIONS
       -exec command ;
              Execute  command;  true  if 0 status is returned.  All following
              arguments to find are taken to be arguments to the command until
              an  argument  consisting of `;' is encountered.  The string `{}'
              is replaced by the current file name being processed  everywhere
              it occurs in the arguments to the command, not just in arguments
              where it is alone, as in some versions of find.  Both  of  these
              constructions might need to be escaped (with a `\') or quoted to
              protect them from expansion by the shell.  The command  is  exe-
              cuted in the starting directory.

NAME
       xargs - build and execute command lines from standard input
本blog WWW

Posted by windtear at July 13, 2005 12:00 AM

本站使用中的任何问题,请与 windtear @ windtear.net 联系
Copyright© 1999-2024 Windtear. All rights reserved.