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