How would I do the above, please?
I am trying to do ${strfuture:1:1} ... then ${strfuture:2:1} i.e. indexed string within a loop so I do not have to write it out fully.
I don't know exactly what you're trying to do, but the variable substitution should work in bash. You could alternatively try using something like this to loop through all characters in the string:
while test -n "$strfuture" ; do
c=${strfuture:0:1}
echo $c
strfuture=${strfuture:1}
done
while test $count -le ${CURRENTRUNSCTRL}
do
if [ "$count" = 1 ]
then mj7777_ver='1' start_mj7777_iteration
fi
if [ "$count" = 2 ]
then mj7777_ver='2' start_mj7777_iteration
fi
if [ "$count" = 3 ]
then mj7777_ver='3' start_mj7777_iteration
fi
if [ "$count" = 4 ]
then mj7777_ver='4' start_mj7777_iteration
fi
if [ "$count" = 5 ]
then mj7777_ver='5' start_mj7777_iteration
fi
if [ "$count" = 6 ]
then mj7777_ver='6' start_mj7777_iteration
fi
if [ "$count" = 7 ]
then mj7777_ver='7' start_mj7777_iteration
fi
if [ "$count" = 8 ]
then mj7777_ver='8' start_mj7777_iteration
fi
if [ "$count" = 9 ]
then mj7777_ver='9' start_mj7777_iteration
fi
let count=count+1
done
to this
strcurrent=123456789
count=1
while test $count -le ${CURRENTRUNSCTRL}
do
ver=${strcurrent:${count}:1}
mj7777_ver=${ver} start_mj7777_iteration
let count=count+1
done
so it is fewer lines and easier to read or add further threads
Thanks for your suggestion though as I will see if I can use it somehow
Thanks Subbeh,
I will need to try as sometimes I need to do fewer than 9 iterations and other times the ver is a character rather than a number but if I can get my head around how to control it, it may work