Using "find" in a script..

Alexander Dalloz alexander.dalloz at uni-bielefeld.de
Tue Apr 20 15:11:17 UTC 2004


Am Di, den 20.04.2004 schrieb WipeOut um 16:51:

> The command that should do its is..
> 
> find /backups/fcws/ -mtime +15 -maxdepth 1 -type d -exec rm -rf {};

> find: missing argument to `-exec'
> 
> Anyone got any ideas? to avoid this?

Others already gave the answer (escaping the ;).

Besides that you better avoid other circumstances (failures like "too
much arguments") by using xargs instead of -exec. So the line from above
would look like

find /backups/fcws/ -mtime +15 -maxdepth 1 \
-type d -print0 | xargs -0 rm -rf

> 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..
> 
> Later..

Alexander


-- 
Alexander Dalloz | Enger, Germany | GPG key 1024D/ED695653 1999-07-13
Fedora GNU/Linux Core 1 (Yarrow) on Athlon CPU kernel 2.4.22-1.2179.nptl
Sirendipity 17:06:53 up 1 day, 23:52, load average: 1.34, 1.28, 1.22 
                   [ Γνωθι σ'αυτον - gnothi seauton ]
             my life is a planetarium - and you are the stars





More information about the fedora-list mailing list