我正在运行命令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]...
所以看起来上述标志与[path...] [expression]
有某种关联,但其含义并不清楚。
答案 0 :(得分:3)
turtle.setworldcoordinates()
是找到的文件的占位符。并且{}
标记;
的{{1}}选项执行的命令的结束。反斜杠转义为分号,因此shell不会将其解释为元字符。
答案 1 :(得分:3)
如果查看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.