linux-tutorial/codes/shell/示例脚本/输入和输出/使用getopts.sh

14 lines
304 B
Bash
Raw Normal View History

2019-05-10 11:17:57 +08:00
#!/bin/bash
2019-10-10 08:56:31 +08:00
2019-05-10 11:17:57 +08:00
# simple demonstration of the getopts command
while getopts :ab:c opt
do
2019-10-10 08:56:31 +08:00
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
2019-05-10 11:17:57 +08:00
done