Why doesn’t this work?
I’m just trying to get char to print the contents of the array, which is the alphabet.
alphabet=(a b c d e f g h i j k l m n o p q r s t u v w x y z)
for char in alphabet
do
echo $char
(($char++))
done
<-This just prints the word “alphabet”
"declare -p alphabet"
"${!alphabet[@]}"
"${#alphabet[@]}"
← these statements work outside the loop, so it seems that the array can be browsed.
If I use for (( char=0; char < "${#alphabet[@]}"; char++ ))
it lists the correct number of the array elements; 0 - 25.
What am I doing wrong?
Any help is appreciated!