I have a loop and I need to be able to unset the array element that I am currently accessing in it. I was thinking of making a counter that increments with the loop and doing unset $dirs[$counter] but if I do that I am not sure if the other members of the array would get shifted down in index (meaning that the second time I unset an element I would unset the element in front of the one that I actually want to unset).
Any help is appreciated.
for x in ${dirs[@]}
do
if [[ $x == $dir* ]]; then
bool=1
# here I need to do unset $dirs[????]....
fi
done