Reputation: 7
I want to cut a variable and use the result to manipulate a variable at this name
`echo ${!var1} | cut -b$var2`=1
But thats don't work. Do you have any idea to do that ?
The complete code
for (( var1=1; ${!var1}!=""; var1++ ))
do for (( var2=1; `echo ${!var1} | cut -b$var2`!=""; var2++ ))
do `echo ${!var1} | cut -b$var2`=1
done
done
Upvotes: 0
Views: 179
Reputation: 189357
Something like this?
ref=${!var1}
printf -v "${ref:$var2:1}" '%s' 1
Upvotes: 1