【发布时间】:2016-10-31 08:09:36
【问题描述】:
在 Kubuntu 15.10 上
echo $BASH_VERSION
4.3.42(1)-release
我试试
reps=1
threads={1}{10..60..10}
for((r=0;r<$reps;r++))
do
tCount=0
for t in $threads
do
echo "t=$t, tCount=${tCount}"
#do something funny with it
((tCount++))
done
done
它会产生一行
t={1}{10..60..10}, tCount=0
如何让它工作?
编辑
我期待
t=1, tCount=0
t=10, tCount=1
t=20, tCount=2
t=30, tCount=3
t=40, tCount=4
t=50, tCount=5
t=60, tCount=6
更新
注意threads=({1}{10..60..10})
然后for t in ${threads[@]}
将在10..60..10 范围前加上字符串{1}
(即{1}10,{1}20,..,{1}60)
【问题讨论】:
-
我推荐使用
threads=$(echo {1}{10..60..10}) -
@hek2mg 这以
{1}为前缀10,20,..,60(即{1}10,{1}20,..,{1}60。这也是为什么这不是重复问题的原因。 -
{1}根本不是必需的。使用它的原因是什么?
标签: bash range brace-expansion