This is driving me nuts as I know it is something easy, but I can't seem to find the solution. Arrgh! I just need to add a find command in to my script so it removes older files before running a new backup. I'd rather control this through variables instead of typing out the exact command. The command does work in the script if I type it out in there instead of using variables.
FIND="/usr/bin/find" BUILD="~/" FINDOPTS="-type f -mtime +3 -exec rm -rf {} \;" echo $find $BUILD $FINDOPTS ## remove the 2 week old backup echo "Removing old backups... " $FIND $BUILD $FINDOPTS
If I just echo the $FIND $BUILD $FINDOPTS
command it shows just like the command does if I type it out. Only difference is it will actually run when I type it.
Typing out /usr/bin/find ~/ -type f -mtime +3 -exec rm -rf {} \;
works just fine.
The error that I get is:
/usr/bin/find: missing argument to `-exec'
Can anyone help explain why this is? Thank you!