In zsh
, `...`
like the modern form $(...)
splits on characters of $IFS
, which by default includes SPC, TAB, NL and NUL.
Of those, only NUL cannot occur in a file path, so you'd need:
IFS=$'\0'
cp $(find /Volumes/DATA/ -name "*.app" -depth 1 -print0 2> /dev/null) /Volumes/VMWare/img/
Or, instead of using the implicit word splitting done by $(...)
using a global parameter, use an explicit splitting operator:
cp ${(0)"$(find /Volumes/DATA/ -name "*.app" -depth 1 -print0 2> /dev/null)"} /Volumes/VMWare/img/
But in any case, using find
here has no benefit whatsoever over:
cp /Volumes/DATA/*.app(D) /Volumes/VMWare/img/
(here using the D
glob qualifier so it also includes hidden files like find
does, though it's likely you'd want to skip them anyway).
{}
won't do anything special.find
already knows how to pass the argument without any shell doing splitting on the value. – Kusalananda Dec 03 '18 at 23:12sh
shells, likecsh
andtcsh
. I'm pointing this out specifically because you make it sound like adding the single quotes is important. It's not. – Kusalananda Dec 04 '18 at 06:14