运行 命令作为 bash 来自 POSIX shell

Run command as bash from POSIX shell

我有一个简单的问题

我有一个 posix shell 但我需要 运行 一个 bash 命令。

想想

root@home:~# sh
# /bin/bash /bin/ls

但是,当我这样做时,我得到

/bin/ls: /bin/ls: cannot execute binary file

我确定我遗漏了一些简单的东西,但我不确定它是什么。有什么帮助吗?我也需要一行完成。

我想出了一个解决方法

echo '#!/bin/bash\--comamnd--; chmod ugo+x /tmp/script.sh; /tmp/script.sh

使用 -c 参数来指定一个你希望被其他 运行 执行的命令 shell:

" -c 从 command_string 操作中读取命令运行d"

bash -c "ls"