From 4548138d125311ec5175d4a5acf2becd15da37d6 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 13 Jan 2024 10:18:23 -0600 Subject: [PATCH] Update power.inc.sh --- inc/power.inc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/power.inc.sh b/inc/power.inc.sh index dbd2d3c8..7100bd3f 100644 --- a/inc/power.inc.sh +++ b/inc/power.inc.sh @@ -6,7 +6,7 @@ AVERAGEPOWER(){ total_amp=0 total_watt=0 while IFS=$'\t' read date amp watt ;do - if [ "${amp}" != "" ] && [ "${watt}" != "" ]; then + if [[ "${amp}" =~ ^[0-9]+$ ]] && [[ "${watt}" =~ ^[0-9]+$ ]]; then total_amp=$(bc <<< "scale=2; ${total_amp}+${amp}") total_watt=$(bc <<< "scale=2; ${total_watt}+${watt}") ((logsfound++)) @@ -24,7 +24,7 @@ AVERAGEPOWER(){ total=0 [ "${3}" != "" ] && ptype=${3} || ptype=watt while IFS=$'\t' read date ${ptype} ;do - if [ "${!ptype}" != "" ]; then + if [[[ "${!ptype}" =~ ^[0-9]+$ ]]; then total=$(bc <<< "scale=2; ${total}+${!ptype}") ((logsfound++)) fi