You have several errors in your code. First, you cannot put whitespace before or after the =
in an assignment statement.
nmin=$(expr ($nr-1)*31)
nmax=$(expr ($nr*31)-1)
Second, expr
is not needed for arithmetic; the shell can do that itself.
nmin=$(( ($nr-1)*31 ))
nmax=$(( ($nr*31)-1 ))
Third, the proper way to assign an array is with parentheses
array=( `ls *d03_*` )
Fourth, it's never appropriate to use ls
like this. Just expand the glob directly into the array:
array=( *d03_* )
Your for
loop is actually almost correct; you should, however, quote the expansion so that any whitespace in each array element is preserved.
for name in "${array[@]:nmin:30}"; do
which iterates over ${array[nmin]}
through ${array[nmin+29]}
.