On Mon, Nov 23, 2015 at 02:23:33PM -0700, Eric Blake wrote: > On 11/23/2015 01:45 PM, Matt D. wrote: > > Is there a reason why these produce different results? > > > > find . -exec cygpath -wa {} \; > > find . -exec echo $(cygpath -wa {}) \; > > Incorrect quoting. You are invoking: > > find . -exec echo c:\cygwin\home\you\{} \; > > (or whatever ./{} resolves to), instead of one cygpath per name found by > find. > > > > > I have to do this which is much slower: > > find . -exec bash -c 'echo $(cygpath -wa {})' \; > > > > This indeed quotes things so that cygpath is now invoked once per file, > but at the expense of an additional bash per file as well. > > Why not just: > > find . -exec cygpath -wa {} + > > since cygpath handles more than one file in an invocation (that is, > using '-exec {} +' rather than '-exec {} \;' is generally faster). > I would be using xargs. Especially under /cygdrive, the "-print0 / xargs -0" combination takes care of spaces and other nasties in file names.
find . -print0 | xargs -0 cygpath -wa For utilities that only accept one argument, you can use xargs -n1 -0; you still get the benefit of -print0. Cheers ... Duncan. -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple