我是新手,需要你的帮助解决这个问题。我有一个bash脚本"start.sh"。我想编写一个带有两个参数的脚本,以便我可以按以下方式运行脚本:
./start.sh -dayoffset 1 -processMode true dayoffset和processMode是我必须脚本化的两个参数。
dayoffset = 1是报告日期(今天) processMode = true或false
./start.sh -dayoffset 1 -processMode true dayoffset和processMode是我必须脚本化的两个参数。
dayoffset = 1是报告日期(今天) processMode = true或false
code
if [ $# -eq 3 ]; then if [ -z "$1" ]; then DAY_OFFSET="-1" else DAY_OFFSET="$1" fi if [ -n "$2" ] && [ $2 = "repeat" ]; then echo "Wiederholungslauf" PARAMETERS="${PARAMETERS} -processMode true" else echo "Default" PARAMETERS="${PARAMETERS} -processMode false"fi
else echo "Wrong count of paramaeters given" batch_exit ficode
- user1983063