I have an array in bash, which is declared as
string='var1/var2/var3';
IFS='/' read -r -a array <<< $string
So the array is ["var1", "var2", "var3"]
I want to add an element at a specified index and then shift the rest of the elements that already exist.
So the resultant array becomes
["var1", "newVar", "var2", "var3"]
I've been trying to do this with and loops but I feel like there's some better more "bash" way of doing this. The array may not be of a fixed length so it needs to be dynamic.