有什么区别?和*在Bash?

时间:2017-10-21 17:39:35

标签: bash sh glob

所以你知道,你做了标准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

据我所知,?用于除定义之外的标志,如果没有输入参数,则*用于。但是,我不确定......

1 个答案:

答案 0 :(得分:1)

Bash中问号与Asterisk的区别:

  

?:匹配任何单个字符

     

*:匹配任意数量的任何字符,包括无

来源:https://en.wikipedia.org/wiki/Glob_(programming)