Using "find" in a script..
Rich Lafferty
rich+rhl at lafferty.ca
Tue Apr 20 14:58:09 UTC 2004
On Tue, Apr 20, 2004 at 03:51:08PM +0100, WipeOut <wipe_out at users.sourceforge.net> wrote:
> Hi,
>
> I am creating a script to do a file backup but I am having isues with
> cleaning out the older backups..
>
> Basically each backup goes into a seperate directory named by date and
> time and I want to remove the directories that are 15 days or more old..
> there will probably be 3 to 4 backups per day..
>
> 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'
The "because" is wrong there; you get that error because of the way
you're calling it. You want:
find [...] -exec rm -rf {} \;
You need to escape the ";" to make sure that find gets it, not the
shell.
Cheers,
-Rich
--
Rich Lafferty --------------+-----------------------------------------------
Ottawa, Ontario, Canada | Save the Pacific Northwest Tree Octopus!
http://www.lafferty.ca/ | http://zapatopi.net/treeoctopus.html
rich at lafferty.ca -----------+-----------------------------------------------
More information about the fedora-list
mailing list