gpt4 book ai didi

docker - 有什么用!意思?找 。\! -用户redis -exec chown redis '{}' +

转载 作者:行者123 更新时间:2023-12-02 20:02:11 27 4
gpt4 key购买 nike

关于redis docker镜像ENTRYPOINT脚本 docker-entrypoint.sh :

#!/bin/sh
set -e

# first arg is `-f` or `--some-option`
# or first arg is `something.conf`
if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then
set -- redis-server "$@"
fi

# allow the container to be started with `--user`
if [ "$1" = 'redis-server' -a "$(id -u)" = '0' ]; then
find . \! -user redis -exec chown redis '{}' +
exec gosu redis "$0" "$@"
fi

exec "$@"
在以下行中:
find . \! -user redis -exec chown redis '{}' +
\!是什么意思?

最佳答案

根据GNU find documentation,您可以互换使用! <expr>-not <expr>来匹配与表达式不匹配的项:
2.11将基元与运算符组合

! expr
-not expr

True if expr is false. In some shells, it is necessary to protect the ‘!’ from shell interpretation by quoting it.


反斜杠( \)在多个shell中使用,例如Bourne-Again Shell( bash),到 escape reserved characters具有特殊的含义,但贝壳没有字面意义,这是 exclamation mark( !)字符的情况。
在这种情况下,正如@ottomeister在其注释中已经提到的那样,此命令会将 chown redis <item>应用于从当前目录中递归找到的所有所有者(尚未所有者)的项目。

关于docker - 有什么用!意思?找 。\! -用户redis -exec chown redis '{}' +,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52704554/

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