- 论坛徽章:
- 0
|
shell 如下所示:
- while [ -n "$1" ]
- do
- case "$1" in
- -a) echo "Found the -a option" ;;
- -b) param="$2"
- echo "Found the -b option, with parameter value $param"
- shift 2
- echo "\$1 is $1 now" ;;
- -c) echo "Found the -c option" ;;
- --) shift
- break ;;
- *) echo "$1 is not an option" ;;
- esac
- echo "\$1 is $1 now"
- shift
- done
复制代码
不好意思,忘记了,输入~
输入如下:
./practice2.sh -a -b test1 -d -c -f
输出结果为:
Found the -a option
$1 is -a now
Found the -b option, with parameter value test1
$1 is -d now
$1 is -d now
Found the -c option
$1 is -c now
-f is not an option
$1 is -f now
问题:
为什么 -d 这个参数 没有输出出来, 理论上 应该会有 -d is not an option 的日志.
问题已经解决: 感谢各位达人
shift 2 改为 shift 就OK了, 呵呵
请高手指点,谢谢
[ 本帖最后由 Jedah3 于 2008-8-11 15:48 编辑 ] |
|