Is it possible to create a variable using a varible? like the script below?
Any help will be apprciated.
#!/bin/bash
for i in {1..10}
do
dog${i}=test${i}
echo $dog${i}
done
making the varible outside of the for loop works but doesnt inside, is there a work around?
I have tried many different uses of brackets and parenthesis but to no success
>Solution :
#!/bin/bash
for i in {1..10}
do
test="dog$i"
val="test$i"
declare "$test=$val"
echo "${!test}"
done