title: Adding 3 to 3 separate variables in a loop
body: <p>I am new to bash scripting and have managed quite well until now without asking questions.</p>
  
  <p>GNU bash, version 4.3.42(1)-release (x86_64-pc-linux-gnu)</p>
  
  <p>xubuntu 15.04</p>
  
  <p>This has me stumped and I think the solution is simple and I am missing something fundamental, but I have been working on this for a week trying many permutations having read multiple threads with no change.</p>
  
  <p>This snippet of code comes at the end of an image processing routine of any number of images separated into R G B channels and processed individually.</p>
  
  <p>The files are prefixed in the order the channels were separated from the original images 0.tiff 1.tiff etc. Now I want to recombine them as follows;</p>
  
  <p>renaming to r g b doesn't help because there can be a hundred or more r g b channels</p>
  
  <pre><code>       R G B
  image1 0 1 2 ... and so on
  image2 3 4 5 ...
  image3 6 7 8 ... 
  </code></pre>
  
  <p>So, combine the first image channels 0 1 2, then increment the values of R G B by 3 to get the next image sequence 3 4 5 and so on.</p>
  
  <p>3 grey channels are combining correctly evidence by correct alignment of the channels and production of a colour image.</p>
  
  <p>The for loop combines 0 1 2 and fails on the rest. I think syntax is the problem in the for line - perhaps the enclosing of the variables R G B, though enclosing the variables does not seem to make a difference.</p>
  
  <p>Otherwise, is it in the reassignment of R G B variables by the addition of 3?</p>
  
  <p>I can usually work this sort of thing out but I have come to an end with it - hence the question...</p>
  
  <pre><code> R=0
      G=1
      B=2
  
      echo "$R, $G, $B"
  
  for i in {$R $G $B}; do convert $R.tiff $G.tiff $B.tiff -set colorspace sRGB -combine RGB_%d_$NAME.tiff
  
      let "R=$R+3"
      let "G=$G+3"
      let "B=$B+3"
  
      done
  </code></pre>
  
  <p>I did try naming a new variable such as ((newvalue=$R+3)) and assigining it to R R=$newvalue - same for G and B, but no change. Processes the first image only.</p>
  
  <p>Thank you.</p>