gpt4 book ai didi

linux - 'sudo find/var/www/html -type d -exec chmod g+s {}\;' 中的 {} 和\是什么意思

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:46:55 35 4
gpt4 key购买 nike

我正在运行命令 sudo find/var/www/html -type d -exec chmod g+s {}\;来自 here

那里说“我们可以通过键入上述命令在我们的 WordPress 安装中的每个目录上设置 setgid 位”。问题是 {}/ 是什么意思?

运行 find --help 给出 Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates |opt|exec|time] [路径...] [表达式]...

所以上面的符号似乎与[path...] [expression]有某种关系,但它们的含义尚不清楚。

最佳答案

如果您查看find 的手册页,您会看到-exec 将为找到的每个结果执行命令。它将通过\;

判断命令结束

它还会插入在 {} 中找到的目录的名称。所以上面的命令说找到/var/www/html 下的每个目录并在其上执行 chmod g+s

手册页摘录:

-exec utility [argument ...] ;
True if the program named utility returns a zero value as its exit status. Optional arguments may be passed to the utility. The expression must be terminated by a semicolon (``;''). If you invoke
find from a shell you may need to quote the semicolon if the shell would otherwise treat it as a control operator. If the string ``{}'' appears anywhere in the utility name or the arguments it is
replaced by the pathname of the current file. Utility will be executed from the directory from which find was executed. Utility and arguments are not subject to the further expansion of shell pat-
terns and constructs.

关于linux - 'sudo find/var/www/html -type d -exec chmod g+s {}\;' 中的 {} 和\是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41433096/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com