[英]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.