regex - Parse numeric sequence into ranges of 20 at the command line -


for sequential range of integers, n1..n2how can use command line tools parse them ranges of length <= n?

example

as specific example, have directory folders named 1253..2050. each folder has script called job.sh, , can submit them in batches of 20 jobs (since each node has 20 cores). thus, want generate following commands:

sample input:

echo {1253..1301} 

for particular case can generate sequence of integers using either /bin/ls or cat runs.txt.

sample output:

qsub -t 1253-1272 array.pbs qsub -t 1273-1292 array.pbs qsub -t 1293-1301 array.pbs 

this should want.

count=20 off=0 dirs=(*)  while (( (off + count) < ${#dirs[@]} ));     qsub -t ${dirs[off]}-${dirs[off+count]} array.pbs     ((off+=count + 1)) done if [ $off -ne ${#dirs[@]} ];     qsub -t ${dirs[off]}-${dirs[@]: -1} array.pbs fi 

that last if not necessary in case , loop sort-of assumes ranges going complete (i'm assuming qsub expects too).


Comments