这是我的shell脚本 -
while getopts ":m" opt; do
case "$opt" in
m)
echo "-m was triggered! $OPTARG was entered" >&2
;;
j)
echo "-j was triggered! $4 was entered" >&2
;;
k)
echo "-k was triggered! $6 was entered" >&2
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
shift $(($OPTIND - 1))
当我运行shell脚本时 -
./test.sh -m hello
我以这种方式获得输出 -
-m was triggered! was entered
我哪里错了?请耐心等待我,因为我对shell脚本完全不熟悉。
答案 0 :(得分:1)
它应该是m:而不是:m
while getopts "m:" opt; do