Home > Blockchain >  Getting error while assigning value to a variable in Unix shell script
Getting error while assigning value to a variable in Unix shell script

Time:11-08

Trying to assign value to a variable as follows

n=2
i='hello'
A$n='$i'

But getting error as "A2=hello: command not found

My aim is to assign 'hello' to A2 variable(by substituting $n as 2 in A$n)

CodePudding user response:

You can use declare to achive this:

n=2
i='hello'
declare A$n=$i
  • Related