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