2013-04-28 104 views
-1

我一直試圖解決這個錯誤2天,但我無法弄清楚錯誤發生在哪裏。你能幫我解決這個小小的錯誤嗎?使用bash腳本的語法錯誤

#!/bin/bash 

ntests=10 
param_vertexes=10 
param_pop=10 

echo -e "\nExecution of parallel with 8 threads for $ntests times." 
par8_time=0 
for i in $(seq $ntests); do 
    output=$(./parallel -t 8 $param_vertexes $param_pop) 
    echo $output 
    par8_time=$par8_time+$(echo $output | cut -d' ' -f6) 
done 
par8_time=$(echo $par8_time | bc) 
echo "Total Iteration/Time: $par8_time" 
echo "Speedup of 8 threads: $(echo -e "scale=10\n"$par8_time/$seq_time | bc)" 

我不斷收到同樣的錯誤

Execution of parallel with 8 threads for 10 times. 
Sequential iterations/time = 23.642725 
Sequential iterations/time = 23.860021 
Sequential iterations/time = 23.703970 
Sequential iterations/time = 23.513577 
Sequential iterations/time = 23.728710 
Sequential iterations/time = 23.790608 
Sequential iterations/time = 23.590524 
Sequential iterations/time = 23.612470 
Sequential iterations/time = 23.653072 
Sequential iterations/time = 23.675878 
Total Iteration/Time: 236.771555 
    (standard_in) 3: syntax error 
    Speedup of 8 threads: 

正如你所看到的,只有問題與我的腳本是syntax error尚未允許腳本來顯示加速比。

任何想法?提前致謝。

回答

0

試試這個:

a=$(echo -e "scale=10;$par8_time/$seq_time" | bc) 
echo "Speedup of 8 threads: $a" 
+0

我試過,但它不能解決問題 – 2013-04-28 23:11:02

+0

它給了我同樣的錯誤「語法錯誤」 – 2013-04-28 23:13:31

1

你從未seq_time,使表達bc試圖評估爲 「236.771555 /」,這給出了一個語法錯誤。

+0

+1好的捕獲沒有看到那個。 – 2013-04-29 00:43:37

+0

非常感謝...我會盡力根據您的評論來解決它 – 2013-04-29 04:08:01