Sujet : Re: Executing Shell Pipelines with ?find? _-exec?
De : heller (at) *nospam* deepsoft.com (Robert Heller)
Groupes : comp.unix.shell comp.os.linux.miscDate : 27. Apr 2024, 17:49:36
Autres entêtes
Organisation : Deepwoods Software
Message-ID : <lpGcnb38WpoNg7D7nZ2dnZfqnPGdnZ2d@giganews.com>
References : 1 2
User-Agent : TkNews 3.0 (1.2.17)
Another option: find ... -print0 | xargs -0 -n 1 ...
At Sat, 27 Apr 2024 13:40:52 -0000 (UTC) Christian Weisgerber <
naddy@mips.inka.de> wrote:
On 2024-04-27, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
find . -name \*.blend -exec \
sh -c '[ $(blendfile_version {} | jq -r .version ) \> 304 ]' \; \
-print
This is problematic because the filename is simply interpolated
into the command string, which is then interpreted by sh. If the
filename contains whitespace or shell meta-characters, the results
will be unexpected. Surrounding the {} with quotes doesn't fix
this completely, because the filename could contain a quote character.
A few days ago, Helmut Waitzmann pointed out a better solution over
on the German group:
find . -name \*.blend -exec sh -c \
'[ $(blendfile_version "$1" | jq -r .version ) \> 304 ]' sh {} \; \
-print
You pass the filename as a positional parameter and reference it
as such in the command string.
-- Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364Deepwoods Software -- Custom Software Serviceshttp://www.deepsoft.com/ -- Linux Administration Servicesheller@deepsoft.com -- Webhosting Services