Bash submit example

#! /bin/bash

# This script replicates a given test with varied parameters
# creating unique submit scripts and executing the submission to the CRC SGE queue

basedir=`pwd`
origTestFol=wwd
templFol=template
origTestDir=$basedir'/'$origTestFol
templFolDir=$basedir'/'$templFol

steps=(0 1 2 3 4 5 6 7 8 9)
primes=(2 3 5 7 11 13 17 19 23 29 31)
trials=(6 7 8 9 10)

for step in ${steps[*]}
  do
    newTestDir=$origTestDir'_nm_'$step
    if [! -d $newTestDir]
      then
        mkdir $newTestDir
      fi
    cd $newTestDir
    for trial in ${trials[*]}
      do
       newTestSubDir=newTestDir'/'$trial
       if [ ! -d $newTestSubDir]
          then
            cp -rf $templFolDir $newTestSubDir
            cd $newTestSubDir   
            sed -i 's/seedvalue/${primes[$trial]}/g wwd.nm.conf
            sed -i 's/stepval/$step/g qsubScript.sh
            qsub qsubScript.sh
            cd $basedir
          fi
       done
  done