[英]questions on Linux command “find -exec {}”
我试图在Subversion中更新文件。 我需要在makefile中添加一行,以建立修改后的代码版本。 这是我试图在make文件中找到位置的命令。
找 。 -name“ * ake *” -exec grep filename {} / dev / null \\;
有用。 但是我的问题是:1.什么是“ \\;” 对于? 如果更改它,将会出现错误消息。
2 / dev / null不会更改结果。 我知道这是处理所有“垃圾信息”的设备。 但在这种情况下,我仍然不太了解。
提前致谢!
\\;
指示要由find
执行的命令的结尾。 需要\\
来停止shell解释;
本身。 从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.
/dev/null
是一个聪明的技巧,花了我一段时间才弄清楚。 如果grep传递了多个文件名,则会在每次匹配之前打印包含的文件名。 /dev/null
充当一个不包含任何匹配项的空文件,但使grep认为总是传递的文件名超过一个。 理查德建议的一个更清晰的替代方法是使用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.