我一直在尝试让我的菜单工作,但是它似乎一次只接受一个参数/选项,我如何让它接受多个选项?
#!/bin/bash
##### Main
function usage
{
echo "
usage: infinidb [[-f file ] [-i] | [-h]] name ...
}
while [ "$1" != "" ]; do
case $1 in
-f | --file ) shift
filename=$1
;;
-i | ) filename2=$2
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
echo $filename
echo $filename2运行脚本时
下面的输出显示了
./script.sh -f苹果-i树
苹果树
发布于 2012-10-30 23:34:21
这对我很管用
#!/bin/bash
while [ "$1" != "" ]; do
case $1 in
-f | --file ) shift
filename=$1
;;
-i ) filename2=$2
;;
esac
shift
done
echo $filename
echo $filename2只有一个-i | )的问题
https://stackoverflow.com/questions/13142284
复制相似问题