bash:迭代浮点数列表

时间:2012-08-10 13:06:13

标签: bash for-loop floating-point

在bash脚本中,我想迭代一个我希望作为参数传递给python中的脚本的值列表。事实证明,$d$minFreq在传递给python脚本时不是浮点数。为什么会这样?

for d in {0.01, 0.05, 0.1}
do
    for i in {1..3}
    do
        someString=`python scrpt1.py -f myfile --delta $d --counter $i| tail -1`
        for minFreq in {0.01, 0.02}
        do
            for bValue in {10..12}
            do
                python testNEW.py $someString -d $bValue $minFreq
            done
        done
    done
done

1 个答案:

答案 0 :(得分:8)

删除空格

for d in {0.01,0.05,0.1}

或者不要使用{}扩展(这里没有必要):

for d in 0.01 0.05 0.1

同样适用于minFreq循环。


正如所写,

for d in {0.01, 0.05, 0.1}

为变量d分配了文字字符串值{0.01,0.05,0.1}