#!/bin/bash if [ $# -le 2 ]; then echo "sbatch failed: no enough input files" exit 1 fi PARALLEL_JOB_LIST=() # first argument is the job file # second and more are the parameter files for PARAM_FILE in "${@:2}"; do SBATCH_OUTPUT=$(sbatch $1 $PARAM_FILE) PARALLEL_JOB_LIST+=($(echo $SBATCH_OUTPUT | grep -oE "[0-9]+")) echo "${SBATCH_OUTPUT}" done # collect the data after all jobs are done # some bash magic to concatenate the jobids seperated with "," IFS="," sbatch --dependency=afterok:"${PARALLEL_JOB_LIST[*]}" collect.batch