Using getopts to process long and short command line options

后端 未结 30 1584
佛祖请我去吃肉
佛祖请我去吃肉 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条回答
  •  孤独总比滥情好
    2020-11-21 23:02

    The built-in getopts can't do this. There is an external getopt(1) program that can do this, but you only get it on Linux from the util-linux package. It comes with an example script getopt-parse.bash.

    There is also a getopts_long written as a shell function.

提交回复
热议问题