bash语法错误:无效的算术运算符

时间:2017-05-12 09:33:44

标签: bash

我有这个bash代码,当我运行它时,它会抛出arithmetic operator error

#!/bin/bash

path=$1;
cluster=`cd $1; df -k . | tail -1 | awk -F: '{print $1}' | awk -F- '{print $1}'`
volume=`cd $1; df -k . | tail -1 | awk '{print $1}' | awk -F: '{print $2}' | awk -F/ '{print $3}'`

if [[ $cluster == *"clap"* ]]; then
avg_latency_val=$(cd /net/kkcmon02/app/whisper/netapp/perf/sanjose/$cluster-cls-mgt/svm/vs0/vol/$volume; whisper-fetch --pretty avg_latency.wsp| tail -n 30 | grep -v None | awk -v N=6 '{ sum += $N } END { if ( NR > 0 ) {print sum/NR} else {print 0}}')

elif [[ $cluster == *"isic"* ]]; then
echo "Graphana can monitor only Netapp volumes & this is a volume coming from Isilon."

else
avg_latency_val=$(cd /net/kkcmon02/app/whisper/netapp/perf7/sanjose/$cluster/vol/$volume; whisper-fetch --pretty avg_latency.wsp| tail -n 30 | grep -v None | awk -v N=6 '{ sum += $N } END { if ( NR > 0 ) {print sum/NR} else {print 0}}')

fi

if [[ "${avg_latency_val}" -le  "30" ]] ; then
    echo "Average Latency on the volume for last 30 mins is "${avg_latency_val}" ms (Good)"

elif [[ "${avg_latency_val}" -gt "30" ]] ; then
    echo "Average Latency on the volume for last 30 mins is "${avg_latency_val}" ms (Bad)"

else
    echo "Average Latency on the volume Looks Good!!"
fi

以下是运行上述代码时发生的错误。请让我知道我在这里做错了什么

  

k_test.sh:第21行:[[:1.98381:语法错误:无效算术   运算符(错误标记为“.98381”)

0 个答案:

没有答案