#!/bin/bash POSITIONAL=() while [[ $# -gt 0 ]] do key="$1" case $key in -e|--epochs) EPOCHS="$2" shift # past argument shift # past value ;; -l|--lr) LR="$2" shift # past argument shift # past value ;; --default) DEFAULT=YES shift # past argument ;; *) # unknown option POSITIONAL+=("$1") # save it in an array for later shift # past argument ;; esac done set -- "${POSITIONAL[@]}" # restore positional parameters if ! [ -z ${EPOCHS} ] && ! [ -z ${LR} ]; then python3 dlgssdpytorch.py with n_epochs=${EPOCHS} lr=${LR} elif ! [ -z ${EPOCHS} ]; then python3 dlgssdpytorch.py with n_epochs=${EPOCHS} elif ! [ -z ${LR} ]; then python3 dlgssdpytorch.py with lr=${LR} else python3 dlgssdpytorch.py fi