对于命令结构-exec command {} \;
,我输入了信息man find
。
selected files
。在有关的段落中-exec command {} +
。
-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 invoca‐
tions 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, and (when find is being invoked
from a shell) it should be quoted (for example, '{}') to protect
it from interpretation by shells. The command is executed in
the starting directory. If any invocation returns a non-zero
value as exit status, then find returns a non-zero exit status.
If find encounters an error, this can sometimes cause an immedi‐
ate exit, so some pending commands may not be run at all. This
variant of -exec always returns true.
它从不说什么+
,bash +是什么意思-exec command {} +
?
它的意思是终止诸如;
?之类的参数。
+
表示加号(例如3+5=8
或)concatenate
,将两个字符串合并为一个字符串(例如s1
+)s2
。
这是指定的意思一件奇怪的事情terminate the argument
了+
。
它与Bash无关,它是find
语法的一部分。该命令必须知道操作在哪里-exec
结束。它在;
或处结束+
。根据终止字符,使用适当的-exec
动作变体。
为什么要为此目的选择这两个字符?我不知道。一些方式来结束-exec
声明是必须的,有人选择了;
和+
。现在,当涉及到find
命令时,这些字符已成为POSIX标准的一部分。
我们只能猜测;
是选择它的原因,因为它也可以在shell中终止命令,因此目的是相似的。出于这个原因,然而,;
需要由被视为find
必须在外壳经过特殊处理的,因此\;
(';'
或者";"
也适用)。不会有这样的问题+
。
从技术上讲,几乎可以选择其他任何字符串来代替+
(与相同;
)。需要注意的是-exec
,{}
,+
和;
(后通过壳感谢逃逸或引用),可能测试或类似的行动-type
或-print
-他们都是参数find
; 它们在find
处理它们时变得有意义,它们的含义来自find
发明的方式。
总结一下:
find
,而不是关于bash
。-exec
操作。-exec
语句参数。这是一种设计选择。;
和+
; 这是一种设计选择。+
(我不知道),这也是琐事,并不是真正有意义的事情。我只能推测{} +
是“一个或多个参数”,例如10+有时表示“十个或多个”。
+
表示加号(例如3+5=8
或)concatenate
,将两个字符串合并为一个字符串(例如s1
+)s2
。赋予含义终止参数是一件很奇怪的事情+
。
怎么样
>
的意思是“大于”…为赋予一个“重定向”的含义是一件很奇怪的事情>
。
“+
意味着加”不是来自上帝。有人决定,其他人紧随其后,标志被粘住了。
+
数学的意思是“加”。>
数学中的意思是“大于”。>
在shell中进行重定向。+
终止。-exec
find
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句