Linux
bash + 如何增加包含字母 a..z 的變數
如何增加變數 - $var 包含字母 a..z
例子:
var=({b..z}) for x in 1 2 3 4 5 do echo $x,$var $var++ ( this is wrong but I need to do something like this ) done
預期輸出:
1,b 2,c 3,d 4,e 5,f . . .
簡單的方法:
echo "$x,$var" var="$(echo $var | tr '[a-y]z' '[b-z]a')"
你有一個數組;只需索引它:
var=( {b..z} ) for ((x=0; x<5; x++)); do echo "$x, ${var[x+1]}" done