问题描述
使用这组命令,什么是{}和\; ?
With this set of commands, what are the {} and \; characters for?
find . -name '*.clj' -exec grep -r resources {} \;
推荐答案
请参阅。 (特别是 -exec
部分)
See man find. (particular the part about -exec
)
使用 -exec
为每个找到的文件运行命令, {}
被替换为找到的每个文件的名称,命令终止 \;
When using -exec
to run a command on each of the files found, the {}
is replaced with the name of each file found, and the command is terminated by \;
在您的示例中,在当前目录下找到的所有文件(。
),匹配 *。clj
将有命令 grep -r resources
In your example, all files found under the current directory (.
), matching the name *.clj
will have the command grep -r resources
run on them (to find the string resources
if it exists in each of those files).
实际上有些多余,因为 c $ c> -r
用于递归搜索子目录,这是找到
已经在做。
It's actually somewhat redundant, since -r
is for recursively searching subdirectories, and that's what find
is already doing.
这篇关于简单unix命令,什么是{}和\;对于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!