我想剪切一个变量,并使用结果以该名称操作变量
`echo ${!var1} | cut -b$var2`=1
但是那是行不通的。你有什么想法吗?
完整代码
for (( var1=1; ${!var1}!=""; var1++ ))
do for (( var2=1; `echo ${!var1} | cut -b$var2`!=""; var2++ ))
do `echo ${!var1} | cut -b$var2`=1
done
done
答案 0 :(得分:1)
像这样吗?
ref=${!var1}
printf -v "${ref:$var2:1}" '%s' 1