bash 找 。-exec echo {} \; = 缺少`-exec'的参数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10722723/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 02:21:59  来源:igfitidea点击:

find . -exec echo {} \; = missing argument to `-exec'

bashfind

提问by Pascal Polleunus

Why doesn't this work? (echo is not the real command)

为什么这不起作用?(回声不是真正的命令)

$ find . -type d -exec echo {}?\;
find: missing argument to `-exec'

I managed to do that anyway like this:

无论如何,我设法这样做:

$ for f in `find . -type d`; do echo $f; done

回答by bakalov

This work for me.

这对我有用。

find . -type f -exec file '{}' \;

Braces are enclosed in single quote marks to protect them from interpretation as shell script punctuation.

大括号用单引号括起来,以防止它们被解释为 shell 脚本标点符号。

回答by djhaskin987

The following line is from the EXAMPLES section of man find:

以下行来自于的示例部分man find

find . -type f -exec file '{}' \;

It looks to me like the {}part needs to be in single quotes.

在我看来,该{}部分需要用单引号括起来。