/bin/bash -c 的意思

youthcityIP属地: 广东
0.513字数 157阅读 22,629

背景

在看 kubernetes 的 yaml 配置文件时,发现很多执行 bash 命令的地方都会带上参数 -c,但是不知道这个参数的含义。

解答

-c 在 bash 手册中的解释:

-c string If the -c option is present, then commands are read from string.  If there are arguments after the string, they are assigned to the positional parameters, starting with $0.

也就是说,-c 命令表示后面的参数将会作为字符串读入作为执行的命令。

举个例子,尝试在本地执行下面两个命令:

  • /bin/bash -c ls
  • /bin/bash ls
执行结果

可以看到, /bin/bash -c 后面接 命令 ,而 /bin/bash 后面接 执行的脚本

相关资料

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
6人点赞
更多精彩内容,就在简书APP
"请我喝喜茶~~"
还没有人赞赏,支持一下
youthcityI will never stop learning and improving my craft.
总资产158共写了5.6W字获得4,036个赞共167个粉丝

全部评论0只看作者
按时间倒序
按时间正序