On 2021-08-05 at 20:25, Greg Wooledge wrote: >> >> find . -type d -exec chmod -v 0644 '{}' \; > >> > Use + instead of \; to make them more efficient. > >> What does + make as a difference ? > > It's a replacement for xargs, except that it actually works, unlike > xargs, which is horribly broken without GNU extensions. > > find . -type d -exec chmod 755 {} + > > is equivalent to > > find . -type d -print0 | xargs -0 chmod 755 > > except that the former is (a) faster, (b) shorter, and (c) POSIX standard.
I believe I've hit contexts in which I could use '-print0 | xargs -0' but couldn't figure out a way to get the job done with '-exec', because I needed the command which was being run to process the output to be a pipeline. (I no longer remember the specifics of the tasks involved, so I can't explain why this was what I needed.) The only way I can/could think of to do that with an argument to '-exec' involved putting the pipeline sequence into a script and calling that via -exec, but that's more unwieldy than I want to work with in most cases. -- The Wanderer The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. -- George Bernard Shaw
signature.asc
Description: OpenPGP digital signature