#! /bin/sh nawk ' BEGIN{ START="'$1'" LAST="'$2'" printf("START=%d, LAST=%d\n", START, LAST) while ( START < LAST ){ first = START second = ++START print "doing " first " and " second dat1=sprintf("%d.dat", first) dat2=sprintf("%d.dat", second) fel1=sprintf("%d.fel", first) fel2=sprintf("%d.fel", second) cmd=sprintf("grad2 -i %s %s -o %s %s", dat1, dat2, fel1, fel2) system( cmd ) START++ } }'