bash - find -exec with \; runs but + terminator fails with "missing argument to -exec" -
this question has answer here:
- trailing arguments find -exec {} + 1 answer
sometimes find
command refuses execute +
terminator -exec
, changing +
\;
allows exec run.
consider, after following setup:
find_args=( -type f -name "*users*" -cmin -60 ) rsync_args=( -avhp -e 'ssh -i /home/some_user/.ssh/id_rsa -c arcfour' ) dest=some_user@some_host:/some/destination/
this works:
# runs rsync once per file, slower should need find . "${find_args[@]}" -exec rsync "${rsync_args[@]}" {} "$dest" \;
...but 1 fails:
# same, except + rather \; # ...should use same rsync call multiple files. find . "${find_args[@]}" -exec rsync "${rsync_args[@]}" {} "$dest" +
...with error find: missing argument '-exec'
.
i'm using gnu findutils 4.4.2, documented support +
argument.
in find -exec ... {} +
, +
must immediately after {}
(and inserted arguments must in trailing position). given command not meet requirement.
consider following workaround:
find . -type f -name "*users*" -cmin -60 \ -exec sh -c 'rsync -avhp -e "ssh -i /home/some_user/.ssh/id_rsa -c arcfour" "$@" some_user@some_host:/some/destination/' _ {} +
because sh -c [...]
line longer rsync
line runs, argument list passed former guaranteed work latter, expanding "$@"
succeed.
Comments
Post a Comment