Re: Using "find" in a script..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 20, 2004 at 03:51:08PM +0100, WipeOut <wipe_out@xxxxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxx -----------+-----------------------------------------------



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux