I have a for loop in bash that operates in an array.
for i in 1..16; do some operation in some file; done
Now, for first 1, or few elements, the operation is not successful, the loop crash and does not iterate over the next elements. Is there any way to keep the iteration running until the last element, whether it fails or not in any step? The actual command looks like
for i in ${list3[@]}; do impute4 -g chr21.haps -h chr21.haplotypes.hap.gz -l chr21.legend.gz -m map_chr21.txt -o test$i.impute -int ${list1[@]}[$i] ${list2[@]}[$i] -Ne 20000 -buffer 1000 -seed 54321 & done
Here
{list3[@]}=0 1 2 3 4 ..16
{list1[@]}=0 3e6 6e6 9e6 12e6 ..48e6
{list2[@]}=3e6 6e6 9e6 12e6 15e6 ..51e6
The -int
flag takes two values start end
of a region.
For first few elements the program crashes because there is no snps in those regions (0 3e6 or 3e6 6e6)
. so I need to move on to the next regions.
How could I do that.