使用getopts

5年以前  |  阅读数:508 次  |  编程语言:Shell 
#!/bin/bash
# simple demonstration of the getopts command

while getopts :ab:c opt
do
    case "$opt" in
    a) echo "Found the -a option";;
    b) echo "Found the -b option, with value $OPTARG";;
    c) echo "Found the -c option";;
    *) echo "Unknown option:$opt";;
    esac
done

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8