I'm wondering to know that what difference is the between using +
and ;
at the end of -exec
command when I use in find
command?
find .... -exec ... \;
VS
find .... -exec ... +
I'm wondering to know that what difference is the between using +
and ;
at the end of -exec
command when I use in find
command?
find .... -exec ... \;
VS
find .... -exec ... +
-exec ... \;
will run one item after another. So if you have three files, the exec line will run three times.-exec ... {} +
is for commands that can take more than one file at a time (egcat
,stat
,ls
). The files found byfind
are chained together like anxargs
command. This means less forking out and for small operations, can mean a substantial speedup.Here's a performance demo catting 10,000 empty files.
Again this only works on commands that can take multiple filenames. You can work out if your command is like that by looking at its manpage. Here's the synopsis from
man cat
:The ellipsis on
[FILE]...
means it can take more than one file.+
can only be used on single commands and you must have exactly one{}
in the line.\;
can operate with multiple zero-to-many groups.