shell bash 参数

#!/bin/bash

while getopts as: opt; do
    case $opt in
        a) printf '%s\n' 'You have chosen: a';;
        s) n=$OPTARG; printf '%s: %d\n' 'You have chosen s with an argument of' "$n";;
    esac
done

使用

./script.sh -s 4