Unix下的find命令,{}和\;是什么?为了? [英] Unix find command, what are the {} and \; for?

查看:83
本文介绍了Unix下的find命令,{}和\;是什么?为了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用这组命令, {} \; 字符是什么?

With this set of commands, what are the {} and \; characters for?

find . -name '*.clj' -exec grep -r resources {} \;

推荐答案

请参见 man找到.(特别是有关 -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 在它们上运行(如果每个文件中都存在字符串 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).

它实际上有点多余,因为 -r 用于递归搜索子目录,而这正是 find 已经在做的事情.

It's actually somewhat redundant, since -r is for recursively searching subdirectories, and that's what find is already doing.

这篇关于Unix下的find命令,{}和\;是什么?为了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆