I am new to bash scripting and have managed quite well until now without asking questions.
GNU bash, version 4.3.42(1)-release (x86_64-pc-linux-gnu)
xubuntu 15.04
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.
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.
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;
renaming to r g b doesn't help because there can be a hundred or more r g b channels
R G B
image1 0 1 2 ... and so on
image2 3 4 5 ...
image3 6 7 8 ...
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.
3 grey channels are combining correctly evidence by correct alignment of the channels and production of a colour image.
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.
Otherwise, is it in the reassignment of R G B variables by the addition of 3?
I can usually work this sort of thing out but I have come to an end with it - hence the question...
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
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.
Thank you.