![我需要从文件中查找最小和最大速率,但无法使最小速率正常工作,有人看到我的错误吗?](https://linux22.com/image/214165/%E6%88%91%E9%9C%80%E8%A6%81%E4%BB%8E%E6%96%87%E4%BB%B6%E4%B8%AD%E6%9F%A5%E6%89%BE%E6%9C%80%E5%B0%8F%E5%92%8C%E6%9C%80%E5%A4%A7%E9%80%9F%E7%8E%87%EF%BC%8C%E4%BD%86%E6%97%A0%E6%B3%95%E4%BD%BF%E6%9C%80%E5%B0%8F%E9%80%9F%E7%8E%87%E6%AD%A3%E5%B8%B8%E5%B7%A5%E4%BD%9C%EF%BC%8C%E6%9C%89%E4%BA%BA%E7%9C%8B%E5%88%B0%E6%88%91%E7%9A%84%E9%94%99%E8%AF%AF%E5%90%97%EF%BC%9F.png)
我需要找到该文件中的最小和最大速率。我已经计算出了最大值,但无法解决最小值。有人对我做错的事情有什么建议吗?这是我的代码:
1 #!/usr/bin/bash
2 echo "Starting"
3 FILE="/var/www/html/bitcoin.txt"
4 COUNT=0
5 MAX=0
6 MIN=""
7 LAST=0
8 PREV=""
9 while read line
10 do
11 COUNT=$(($COUNT+1))
12 RATE=$( echo "$line" | jq . )
13 if [[ $RATE > $LAST ]]
14 then
15 LAST=$RATE
16 MAX=$LAST
17 fi
18
19 if [[ $PREV < $RATE ]]
20 then
21 PREV=$RATE
22 MIN=$PREV
23 fi
24
25 done < $FILE
26 echo "maximum: "
27 echo "The max is $MAX"
28 echo "minimum: "
29 echo "The min is $MIN"
30 echo "Finished!"
31
32 # the max is correct, gives max of 59181.2048
33 # min is stuck on 0?