我想用一个case语句脚本之间导致的选择,其他名单(排序的子菜单)之间选择运行一个脚本:bash脚本,case语句和子菜单
#!/bin/bash
echo "Your choice ?"
echo "1) Foo"
echo "2) Bar"
echo "3) Stuff"
read case;
case $case in
#and this is where I would like to allow
#(here a simplified example I do not manage to code)
1) What script ? # may I use another case statement ?
a) Foo1;;
b) Foo2;;
2) What script ? # d°
a) Bar1;;
b) Bar2;;
c) Bar3;;
esac
Foo1和Foo2 ,Bar1,Bar2和Bar3实际上是bash脚本,我想在脚本中调用,例如sh Foo1。
我该如何进行: 我可以在case语句中包含case语句吗(比if语句更好,如果选项很多)? 如何从另一个脚本中调用脚本?
在此先感谢您的帮助
ThG的长度
要从脚本中调用脚本,只需调用其他脚本的名称,就像从命令行执行一样。 – chrisaycock