bash -c "command" 与command有何区别?

terminal中,直接输入command 和 输入bash -c "command" 有何区别?

回答:

shell 有很多种的,bash -c 是为了保证命令使用 bash shell 来执行。如果你使用的默认 shell 就是 bash 那么就没有区别。

// 查看支持的 shell

cat /etc/shells

// 查看正在使用的 shell

echo $SHELL

回答:

同样的疑问,求解。
QQ图片20200629114610.png

#:ps

PID TTY TIME CMD

110933 pts/0 00:00:00 bash

110981 pts/0 00:00:00 ps

#:which bash

/usr/bin/bash

#:/usr/bin/bash -c "i=1;while true;do echo "$i,Hello.";sleep 1;i=`expr $i + 1`;done"

,Hello.

,Hello.

,Hello.

,Hello.

,Hello.

,Hello.

^C

以上是 bash -c "command" 与command有何区别? 的全部内容, 来源链接: utcz.com/p/193884.html

回到顶部