0

我在 repl.it 上使用 Bash。我正在制作自己的命令行,我想知道如何从名为 commands 的文件夹中运行脚本。基本上,我想让一个文件从一个文件夹运行。我怎样才能做到这一点?

描述我想做什么的图片

链接到我的repl

4

1 回答 1

0

你能像这样运行它吗?

sh commands/${input}.sh

此外,您应该能够 push/pop dir 进入/退出目录。

pushd commands
# adds cwd into a stack and goes to <dir> commands/
sh $input.sh
popd 
# goes back to last dir in stack.  
于 2018-11-07T15:20:24.637 回答