bash find -exec sometimes works and sometimes doesn't

148 Views Asked by At

I'm probably missing something, but this oneliner in a bash-script to cycle through some scripts that dump data from different sources:

find . -name 'dump-*.sh' -exec {} "$DUMP_LOG" &>>"$DUMP_LOG" \;

will work when I execute the bash-script containing this oneliner directly, but it doesn't work when I invoke it as the cmd_preexec in rsnapshot. It doesn't spawn any errors, it just doesn't do anything.

I tried adding '(/bin/)bash -c', like this:

find . -name 'dump-*.sh' -exec bash -c '{} "$DUMP_LOG" &>>"$DUMP_LOG"' \;

but then I get an error about '(/bin/)bash not existing, even if Irun the script directly.

1

There are 1 best solutions below

0
On

OK, silly me. Of course the first parameter of the find-cmd needs the working directory.

find /usr/local/sbin -name 'dump-*.sh' -exec {} "$DUMP_LOG" &>>"$DUMP_LOG" \;

has solved the problem.