The let command forces an arithmetic evaluation, and the reference "variable" does not exist, so you get the default value of 0.
y=5 x=y; echo $x # prints: y let x=y; echo $x # prints: 5
Do this instead:
framenr=$(( 1 + (y * cols * resolutions) + (x * resolutions) + res )) echo $framenr: # if your bash version is recent enough printf -v framename 'frame_%03d' $framenr # otherwise framename=$(printf 'frame_%03d' $framenr) echo $framename
I remember reading somewhere that $[ ] deprecated. Use $(( )) instead.
source share