[英]questions on Linux command “find -exec {}”
I tried to update a file in subversion. 我试图在Subversion中更新文件。 I need to add a line in makefile, in order to build up the revised version of code.
我需要在makefile中添加一行,以建立修改后的代码版本。 Here is the command I tried to find the place in make file.
这是我试图在make文件中找到位置的命令。
find .
找 。 -name "*ake*" -exec grep filename {} /dev/null \\;
-name“ * ake *” -exec grep filename {} / dev / null \\;
It works. 有用。 But my questions are: 1. What is the "\\;"
但是我的问题是:1.什么是“ \\;” for?
对于? If I change it, there will be error message.
如果更改它,将会出现错误消息。
2 The /dev/null didn't change the results. 2 / dev / null不会更改结果。 I know this is the device where dispose all the "garbage information".
我知道这是处理所有“垃圾信息”的设备。 But I still don't quite understand it in this situation.
但在这种情况下,我仍然不太了解。
Thanks in advance! 提前致谢!
The \\;
\\;
indicates the end of the command to be executed by find
. 指示要由
find
执行的命令的结尾。 The \\
is required to stop the shell interpreting the ;
需要
\\
来停止shell解释;
itself. 本身。 From
man find
: 从
man find
:
-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 /dev/null
is a clever trick that took me a while to figure out. /dev/null
是一个聪明的技巧,花了我一段时间才弄清楚。 If grep is passed more than one filename it prints the containing filename before each match. 如果grep传递了多个文件名,则会在每次匹配之前打印包含的文件名。
/dev/null
acts as an empty file containing no matches, but makes grep think it is always passed more then one filename. /dev/null
充当一个不包含任何匹配项的空文件,但使grep认为总是传递的文件名超过一个。 A much clearer alternative suggested by richard would be to use grep's -H
option: 理查德建议的一个更清晰的替代方法是使用grep的
-H
选项:
-H, --with-filename
Print the filename for each match. This is the default when there
is more than one file to search.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.