#! bin/bash
# code for train.sh
while getopts "f:" flag
do
case $flag in
f)
echo "Hi"
STARTPOINT = $OPTARG
;;
esac
done
echo Test range: $4
echo Train range: $3
#path of experiment folder and data folder:
EXP_DIR="$1"
DATA_DIR="$2"
echo Experiment: $EXP_DIR
echo DataSet: $DATA_DIR
echo file: $STARTPOINT
I ran the command > ./train.sh test1 test2 test3 test4 -f testf
并得到了输出
Test range: test4
Train range: test3
Experiment: test1
DataSet: test2
file:
因此 getopts 选项似乎由于某种原因不起作用,因为您可以看到文件后没有打印任何内容,并且在 case 语句中未执行 echo "Hi" 命令。谁能帮我解决这个问题?