0

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
wxi
  • 7
  • 4

1 Answers1

1

Something like this?

ref=${!var1}
printf -v "${ref:$var2:1}" '%s' 1
tripleee
  • 175,061
  • 34
  • 275
  • 318