和有什么区别?和 * 在 Bash 中?
What is the difference between ? and * in Bash?
所以你知道,你做你的标准 getopts
设置:
while getopts :a:bc option
do
case "${option}"
in
a)
# do a manditory thing!
;;
b)
# do a optional thing!
;;
c)
# for real, you usually would set variables using getopts
;;
?) # unexpected flag(?)
echo "FATAL: Unexpected flag ${OPTARG}"
exit 2
;;
*) # litterally nothing entered(?)
show_help
exit 1
;;
esac
done
据我所知,?
用于未定义的标志,*
用于未输入参数的情况。但是,我不确定....
Bash中问号和星号的区别:
?
: matches any single character
*
: matches any number of any characters including none
所以你知道,你做你的标准 getopts
设置:
while getopts :a:bc option
do
case "${option}"
in
a)
# do a manditory thing!
;;
b)
# do a optional thing!
;;
c)
# for real, you usually would set variables using getopts
;;
?) # unexpected flag(?)
echo "FATAL: Unexpected flag ${OPTARG}"
exit 2
;;
*) # litterally nothing entered(?)
show_help
exit 1
;;
esac
done
据我所知,?
用于未定义的标志,*
用于未输入参数的情况。但是,我不确定....
Bash中问号和星号的区别:
?
: matches any single character
*
: matches any number of any characters including none