On 2020-04-16 12:31, Michael Orlitzky wrote:
> find -name 'whatever' \
> -exec sh -c "
> for f in \"\${@}\"; do
> do_stuff \"\${f}\" && echo \"\${f}\"
> done
> " - {} +
# untested, use at own risk
NL='
'
export NL
AWKPROG='{print "do_stuff @" $0 "@ && printf %s @" $0 "@ :$NL:";}'
AWKPROG=${AWKPROG//@/"'"} ; AWKPROG=${AWKPROG//:/'"'}
find -name "$FOO" | awk "$AWKPROG" | sh
This should work even if sh is dash - only the AWKPROG translations are
bash specific (and they could probably be avoided at the cost of other
ugliness, maybe with sed).
BTW, the only difference between $FOO and ${FOO} is to protect against
alphanumerics literally following the occurence of FOO. It has no
quoting effect on the _contents_ of $FOO.
--
Ian