我需要找到该文件中的最小和最大速率。我已经计算出了最大值,但无法解决最小值。有人对我做错的事情有什么建议吗?这是我的代码:
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?