HowTo: Use bash effectively

a) Create loop with variable range in bash:

for (( s=1; s<=${#sources[*]}; s++ ))
do
  ...
done

b) Perform action for each file of given type:

for texfile in *.tex; do ./makedoc; done