docker - \! 是什么意思?意思是?寻找 。\!-user redis -exec chown redis '{}' +
问题描述
关于 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 文档,您可以同时使用! <expr>
或-not <expr>
交替使用来匹配与表达式不匹配的项目:
2.11 将基本元素与运算符结合起来
!expr
- 不是expr如果expr为假,则为真。在某些 shell 中,有必要保护 '!' 通过引用它来自shell解释。
反斜杠 ( \
) 用于多个 shell,例如 Bourne-Again Shell ( bash
),以转义具有特殊含义的保留字符,这些字符不是由 shell 逐字评估的,感叹号( !
) 字符就是这种情况。
在这种情况下,正如@ottomeister 在他的评论中已经提到的那样,这个命令将应用于chown redis <item>
从当前目录递归找到的所有项目,其所有者还不是 redis。
推荐阅读
- python - 即使我返回所有内容,我的代码的递归似乎也不起作用
- java - Spring-Cache CacheManager 上的 SPI 是什么意思
- php - 从同一表单上传和重命名多个文件的问题
- google-apps-script - 取消选中 Google 表格中的复选框
- python - pyqtdeploy-sysroot:无法检测到 MSVC2015 或 MSVC2017
- mysql - MySQL选择具有每个不同值的随机行 - 逗号分隔输入
- asp.net-mvc - 无法使用 .net framework 4.5 安装 dapper 2.0.30
- c# - Azure 反序列化 JSON 响应 C#
- php - Yii2 命令控制器功能未在 docker 容器的 crontab 中执行
- dependency-injection - 带有任务调度的NestJs依赖注入不起作用