/bin/sh -c 是什么?

问题描述 投票:0回答:3

/bin/sh -c
是什么意思?
-c
有什么作用?

linux sh
3个回答
71
投票

来自 bash 的手册页:

-c string

如果存在

-c
选项,则从
string
读取命令。如果字符串后面有参数,它们将被分配给位置参数,以
$0
开头。

示例:

$ bash -c ls

将启动 bash 并执行命令

ls

/bin/sh
通常是 shell 的符号链接。


1
投票

使用 -c (命令)它返回到第一个 shell,而不是让打开一个新的 shell。
它非常类似于:

sudo su -l -c 'echo "run a command and return"'

示例:

#sudo su -l knoppix -c 'echo "run a command as ${USER} and return"'
run a command as knoppix and return
#

0
投票

sh -c 将创建一个新的 shell 实例。

© www.soinside.com 2019 - 2024. All rights reserved.