美文网首页
/bin/bash -c 的意思

/bin/bash -c 的意思

作者: youthcity | 来源:发表于2020-08-30 12:02 被阅读0次

背景

在看 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 后面接 执行的脚本

相关资料

相关文章

网友评论

      本文标题:/bin/bash -c 的意思

      本文链接:https://www.haomeiwen.com/subject/uvtesktx.html