You can find all this information in the man pages.
I always search for the argument i need, for example I just opened the man page for find and searched for the +
sign.
I was able to find:
-exec command {} + This variant of the -exec action runs the specified command on the selected files, but the command line is built by
appending each selected file name at the end; the total number of
invocations of the command will be much less than the number of
matched files. The command line is built in much the same way that
xargs builds its command lines. Only one instance of '{}' is allowed
within the command. The command is executed in the starting directory.
Perhaps it becomes more clear when you look at the entry before:
-exec command ; Execute command; true if 0 status is returned. All following arguments to find are taken to be arguments to the command
until an argument consisting of ';' is encountered. The string '{}' is
replaced by the current file name being processed everywhere it occurs
in the arguments to the command, not just in arguments where it is
alone, as in some versions of find. Both of these constructions might
need to be escaped (with a '\') or quoted to protect them from
expansion by the shell. See the EXAMPLES section for examples of the
use of the -exec option. The specified command is run once for each
matched file. The command is executed in the starting directory. There
are unavoidable security problems surrounding use of the -exec action;
you should use the -execdir option instead.
reference man find
Feel free to correct me if I am wrong.
– Vinay Jul 25 '18 at 08:21grep -H 'XYZ' ABC.txt ABC2.txt
. You’d get the equivalent ofgrep -H 'XYZ' ABC.txt; grep -H 'XYZ' ABC2.txt
if you used;
instead of+
. – Stephen Kitt Jul 25 '18 at 08:22find . -name "ABC" -exec grep -H 'XYZ' {}|grep -v 'DEF' +
But give me error. – Vinay Jul 25 '18 at 08:41XYZ
, and would then remove the lines from that that matchedDEF
in either the text or the pathname (because of the-H
used with the firstgrep
). – Kusalananda Jul 25 '18 at 08:58find -exec {} +
has been introduced by David Korn in 1989, but it was undocumented until 1995 when it was added to POSIX. The people from the GNU universe rarely know it since GNU find was the last find implementation that added support for it, so people from that universe frequently use the inferior and vendor unique-print0
. – schily Jul 25 '18 at 09:22