[quote] #!/bin/sh #getopt1 #set the vars ALL=false HELP=false FILE=false VERBOSE=false COPIES=0 while getopts :ahfgvc: OPTION do case $OPTION in a) ALL=true echo "ALL is $ALL" ;; h) HELP=true echo "HELP is $HELP" ;; f) FILE=true echo "FILE is $FILE" ;; v) VERBOSE=true echo "VERBOSE is $VERBOS...
#!/bin/sh USAGE="`basename $0` [-c] [-v] [-f] filename" while getopts f:cv OPTION 2>/dev/null do case $OPTION in f) name=$option ;; c) echo "cccccccccccccc" ;; v) echo "vvvvvvvvvvvvvvv";; \?) echo "$USAGE" exit 1 ;; esac done echo $name 后面跟上 -f 参数 的时候,怎么f赋给了name 其他的都行
要说getopts有bug根本就不可能! 但下面的现象让我难以理解, 谁能解释下? 还是我自己有啥问题? $ cat test.sh while getopts ':a:b:' opt do case $opt in a)echo $OPTARG ;; b)echo $OPTARG ;; ...
TEMP=`getopt -o ab:c:: --long a-long,b-long:,c-long:: -n 'example.bash' -- "$@"` 红色那部分代表啥意思啊?好像man中没看到这部分的语法?
1)what the different between them? 2)i can't understand man getopt and getopts 3)please give some pic to explain it..... thanks
while getopts ":abcde:fg" Option 这名话里的第一个 :怎么理解,还有就是getopts结构的具体用处是什么,有什么好处? 谁能详细的解释下啊,看了很多资料都还没理解!!!!!
#!/usr/bin/ksh while getopts ":s:" ARGUMENT do case $ARGUMENT in s) echo $OPTARG ;; \?) echo "error" ;; esac done ./脚本名 -9.9 结果为 error error error 重复输出3行 如果执行./脚本名 -s 1 则只输出1 why
在redhat as 4下按照linux和unix shell编程指南上的例子用getopts出错,脚本如下: #!/bin/sh #getopt1.sh COPIES=0 while getopts :vc: OPTION do case $OPTION in v) VERBOSE=true echo "VERBOSE is $VERBOSE" ;; c) echo "c is specified" COPIES=$OPTARG echo "COPIES is $COPIES" ;; \?) echo "`basename ...