I'm using Bash 4.3.8 on an Ubuntu system, and no matter what I try, incrementing a counter won't work. The simplest example would be something like this:
#!/bin/bash
myVar=0
myVar=$((myVar++))
echo myVar
The variable should be 1, but it's always 0. I've tried every increment method I know, including:
The while loop, in this case runs in another subshell with its own scope of variables, which are created and destroy as the while loop starts and finishes.
Thank you both, I didn't know that bash runs in subshells. I learn something new every day, that's the mark of a good Friday. Everything's working fine now.