# 定义长选项
LONGOPTS="help,pname:,dur:,freq:,core:,platform:,id:"
# 解析选项
PARSED=$(getopt -o hp:d:F:C: --long "$LONGOPTS" -- "$@")
# Check for getopt errors
if [ $? -ne 0 ]; then
exit 1
fi
# 将解析结果作为参数集合
eval set -- "$PARSED"
# 设置输入参数默认值
platform=""
PLATFORM_ID=""
pname=""
dur="300"
freq="199"
core=""
# 循环解析参数
while true; do
case "$1" in
-h|--help)
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -h, --help Print this help message"
echo " -p, --pname=NAME Specify pname"
echo " -d, --dur=DURATION Specify duration"
echo " -F, --freq=FREQUENCY Specify frequency"
echo " -C, --core=CORE Specify core"
exit 0
;;
-p|--pname)
pname="$2"
shift 2
;;
-d|--dur)
dur="$2"
shift 2
;;
-F|--freq)
freq="$2"
shift 2
;;
-C|--core)
core="$2"
shift 2
;;
--)
shift
break
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done