Hi

On Sun, 28 May 2023 08:49:22 -0400 Max Pyziur wrote:

> When I issue a command such as:
> tar zcvf /var/tmp/SomeArchive.tgz `find . -iname '*pdf' -type f`

> and it encounters a filename such as  ./My Documents/SomeFile.pdf

> The results are:
> tar: ./My: Cannot stat: No such file or directory
> tar: Documents/SomeFile.pdf: Cannot stat: No such file or directory

Use for example:

  find . -iname '*pdf' -type f \
    | tar zcvf /var/tmp/SomeArchive.tgz --files-from=- --verbatim-files-from

This assumes that no filename contains a linefeed.

> Similar results happen with this command:
> chmod 644 `find . -iname '*pdf' -type f -perm 755`

Th following will do I think:

  find . -iname '*pdf' -type f -perm 755 -print0 \
    | xargs -0 chmod 644

Notes:

  Generating a potential very long command line like you do may fail due to a
  maximum length allowed. Use xargs or --files-from if the command provides it
  (like tar and rsync at least).

  The use of `CMD` is discouraged. Use instead $(CMD):
    - more readbale
    - for more easy to nest

-- 
francis
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to