- Option 1: (used by <https://github.com/statgen/SLURM-examples/blob/master/job-array-one-command-per-line>) ``` #!/bin/bash #SBATCH --array=1-2 declare -a commands commands[1]="Rscript myscript.R input_file_A.txt" commands[2]="Rscript myscript.R input_file_B.txt" bash -c "${commands[${SLURM_ARRAY_TASK_ID}]}" ``` - Option 2: ``` #!/bin/bash #SBATCH --array=1-2 commands=( "Rscript myscript.R input_file_A.txt" "Rscript myscript.R input_file_B.txt" ) bash -c "${commands[${SLURM_ARRAY_TASK_ID}]}" ``` - Option 3: ``` #!/bin/bash #SBATCH --array=1-2 read -d '' commands <<'EOF' Rscript myscript.R input_file_A.txt Rscript myscript.R input_file_B.txt EOF echo "$commands" | sed -n ${SLURM_ARRAY_TASK_ID}p | bash ``` - Option 4: somewhere there's a script (maybe written by Terry?) that does this.
Option 1: (used by https://github.com/statgen/SLURM-examples/blob/master/job-array-one-command-per-line)
Option 2:
Option 3:
Option 4: somewhere there's a script (maybe written by Terry?) that does this.