I am learning shell(ksh) scripting. I wanted to know what does ${array[three]} mean in this context.
array[1]="one"
array[2]="two"
array[3]="three"
three=3
print ${array[1]}
print ${array[2]}
print ${array[3]}
print ${array[three]}
The Output:
one
two
three
three
I understand that we just declare a simple array that holds {one,two,three} as it’s values. But i dont understand why print ${array[three]} outputs three. My main double is isnt it should be print ${array[$three]}
You can also write:
and it will produce the same answer (
three). It appears that within the scope of the${...}, the Korn shell automatically assumes that any word that could be a variable name is and implicitly applies the$to it.