Re: Executing Shell Pipelines with ?find? _-exec?

Liste des GroupesRevenir à cu shell 
Sujet : Re: Executing Shell Pipelines with ?find? _-exec?
De : heller (at) *nospam* deepsoft.com (Robert Heller)
Groupes : comp.unix.shell comp.os.linux.misc
Date : 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-5364
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
heller@deepsoft.com       -- Webhosting Services
                                                  

Date Sujet#  Auteur
27 Apr 24 * Executing Shell Pipelines with “find -exec”8Lawrence D'Oliveiro
27 Apr 24 +* Re: Executing Shell Pipelines with “find -exec”6Christian Weisgerber
27 Apr 24 i+* Re: Executing Shell Pipelines with ?find? _-exec?4Robert Heller
27 Apr 24 ii`* Re: Executing Shell Pipelines with ?find? _-exec?3Kaz Kylheku
27 Apr 24 ii `* Re: Executing Shell Pipelines with ?find? _-exec?2Robert Heller
5 May 24 ii  `- Re: Executing Shell Pipelines with ?find? _-exec?1Friedhelm Waitzmann
28 Apr 24 i`- Re: Executing Shell Pipelines with “find -exec”1Lawrence D'Oliveiro
5 May 24 `- Re: Executing Shell Pipelines with “find -exec”1Friedhelm Waitzmann

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal