diff --git a/avail.sh b/avail.sh index f37542b..cac6730 100755 --- a/avail.sh +++ b/avail.sh @@ -65,7 +65,7 @@ if [[ $mode == "s" ]]; then diagram="${diagram}[server]\n" eq="${eq} * 100" answer=$(echo "scale=9; $eq" | bc) - answershort=$(echo "$answer" | sed 's/\(\.[^0]\+\)0\+/\1/') + answershort=$(echo "$answer" | sed '/\./ s/\.\{0,1\}0\{1,\}$//') if [[ $answershort == 99.* ]]; then nines=$(echo $answershort | tr -d -C 9 | wc -c | tr -d ' ') [[ $nines -eq 1 ]] && ess="" || ess="s" @@ -186,7 +186,7 @@ elif [[ $mode == "p" ]]; then eq="(1 - (1 - (${sysuptime}/100))^${nsites})*100" answer=$(echo "scale=15; $eq" | bc) - answershort=$(echo "$answer" | sed 's/\(\.[^0]\+\)0\+/\1/') + answershort=$(echo "$answer" | sed '/\./ s/\.\{0,1\}0\{1,\}$//') if [[ $answershort == 99.* ]]; then nines=$(echo $answershort | tr -d -C 9 | wc -c | tr -d ' ') [[ $nines -eq 1 ]] && ess="" || ess="s"