1 |
On Wednesday 23 January 2008, Steve Long wrote: |
2 |
> Ryan Hill wrote: |
3 |
> > Donnie Berkholz wrote: |
4 |
> >> On 12:15 Mon 21 Jan , Jean-Noel Rivasseau (elvanor) wrote: |
5 |
> >>> # No warnings / Java 5 / all output should be directed to stdout |
6 |
> >>> find "${S}" -type f -name '*.xml' -exec \ |
7 |
> >>> sed -r -e "s:(-encoding ISO-8859-1):\1 -nowarn:g" -e |
8 |
> >>> "s:(\"compilerArg\" value=\"):\1-nowarn :g" \ -e "s:(<property |
9 |
> >>> name=\"javacSource\" value=)\".*\":\1\"1.5\":g" \ -e "s:(<property |
10 |
> >>> name=\"javacTarget\" value=)\".*\":\1\"1.5\":g" -e |
11 |
> >>> "s:output=\".*(txt|log).*\"::g" -i {} \; |
12 |
> >> |
13 |
> >> I think this will end up calling sed a large number of times, since |
14 |
> >> -exec runs per file found instead of once on all files. If you instead |
15 |
> >> pipe find output to xargs sed, that might work better. Depending on how |
16 |
> >> many files are involved, this could be a significant difference. |
17 |
> > |
18 |
> > Better yet, use |
19 |
> > |
20 |
> > find [...] -print0 | xargs -0 sed -r -e [...] -e [...] -i |
21 |
> > |
22 |
> > This handles files with special characters like spaces in their names. |
23 |
> |
24 |
> Or even: find blah -exec sed 'blah "blah"' + |
25 |
> It's POSIX[1] and it's in GNU too (after a long delay). The quoting there |
26 |
> is a bit yuck. |
27 |
> http://wooledge.org/mywiki/UsingFind |
28 |
|
29 |
we specifically discourage `find -exec` in favor of `find -print0 | xargs -0` |
30 |
because it sucks. if your system doesnt support `find -print0` or |
31 |
`xargs -0`, then you need to install GNU findutils. or install a real OS. |
32 |
-mike |