Search code examples
bashshellcygwinechocsh

How do you echo a string from a list in cygwin shell script


seven="( . 1 . 1 . 1)"
octal="zero one two three four five six seven"

for n in $octal
do
   echo $n
done

When this gets to seven it echos "seven". How do you get it to echo ( . 1 . 1 . 1) which is the string for $seven?


Solution

  • seven="( . 1 . 1 . 1)"
    octal="zero one two three four five six seven"
    
    for n in $octal
    do
       echo "${!n:-$n}"
    done