I am trying to loop though an array in bash. The array is "AARON" currently that array fills index 0 with AARON. I want to be behave as such
ara[0] = A
ara[1] = A
ara[2] = R
ara[3] = O
ara[4] = N
My script currently looks like this.
#!/bin/bash declare count declare -a ara=(AARON) for name in {A..Z} do count=$((count++)) for char in ${ara[*]} do if [[ ${ara[char]} -eq $name ]] echo ${ara[char]} # for debugging purposes. then sum=$((sum + count)) fi done done echo $sum #for debugging purposes. Normally I would achieve this by setting a custom IFS but I don't know how I would do that for each character of string.