如何在bash中使用getopts的示例
myscript
$ ./myscript -s 45 -p any_string
$ ./myscript -h >>> should display help $ ./myscript >>> should display help
getopt
-s
-s
-p
./myscript -h
./myscript
#!/bin/bashwhile getopts "h:s:" arg; do case $arg in h) echo "usage" ;; s) strength=$OPTARG echo $strength ;; esacdone
getopt
?
富国沪深
相关分类