简单unix命令,什么是{}和\;对于 [英] Simple unix command, what is the {} and \; for

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

问题描述

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

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

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


推荐答案

请参阅 man find 。 (特别是 -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命令,什么是{}和\;对于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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