我有以下 bash 脚本
pass="kall"
cnumb="000000000000"
for (( i=0; i<${#pass}; i++))
do
code=`printf '%03d' "'${pass:i:i+1}"` #generate the code ASCII of letter as string with 3 chars
cnumb = .... #put the code ASCII of "k" in the first bloc of 3 chars , put the code ASCII of "a" in the second bloc of 3 chars, ...
done
如代码中所述,我想在循环中的每次迭代中将 cnumb 中的 3 个字符块替换为另一个 3 个字符块。如何用 bash 做到这一点
是否可以用代码替换子字符串${cnumb:i:i+3}
?