我希望能运行一个脚本,其中包含一个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