Using getopts to process long and short command line options

后端 未结 30 1641
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-21 22:52

I wish to have long and short forms of command line options invoked using my shell script.

I know that getopts can be used, but like in Perl, I have not

30条回答
  •  闹比i
    闹比i (楼主)
    2020-11-21 23:01

    In ksh93, getopts does support long names...

    while getopts "f(file):s(server):" flag
    do
        echo "$flag" $OPTIND $OPTARG
    done
    

    Or so the tutorials I have found have said. Try it and see.

提交回复
热议问题