Using "find" in a script..

Torsten Eberhardt torsten.eberhardt at fireball.de
Tue Apr 20 15:03:51 UTC 2004


Hi,

> The command that should do its is..
> 
> find /backups/fcws/ -mtime +15 -maxdepth 1 -type d -exec rm -rf {};
> 
> The problem is that because there are currently no directories to delete 
> I get the error..
> 
> find: missing argument to `-exec'
> 
> Anyone got any ideas? to avoid this?
> 
> Otherwise I am going to have to create an "if" routine to test first if 
> there are any to delete and if there are then run the command otherwise 
> skip it..

cd /backups/fcws
find . -mtime +15 -maxdepth 1 -type d -exec rm -rf {} \;


does the trick even if there are no directories right now.


Cheers,


Torsten
-- 
******************************************************
* Spam isn't speech, just like a note wrapped around *
* a brick thrown through a window isn't publication. *
******************************************************
    __  __      __       http://www.fireball.de
   / / / /     /_/       Torsten Eberhardt
  / / / /___  ____  __   Lycos Europe GmbH
 / /_/ / __ \/ /\ \/ /   20444 Hamburg
/_____/_/ /_/_/ /_/\_\   +49(0)40 3703-7720 FAX -7757

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20040420/d6cb2fac/attachment-0001.sig>


More information about the fedora-list mailing list