-exec
is the right answer and you don't even need bash -c
in this particular case. If you ever really need to use bash -c
(or sh -c
or so) with -exec
(or with xargs
), do not embed {}
in the shell code. This means your "it works" is somewhat flawed in general.