You can do something like this:
RES=$(sbatch simulation) && sbatch --dependency=afterok:${RES##* } postprocessing
The RES
variable will hold the result of the sbatch
command, something like Submitted batch job 102045
. The construct ${RES##* }
isolates the last word (see more info here), in the current case the job id. The &&
part ensures you do not try to submit the second job in the case the first submission fails.