From 8e88c825177a45ac2c43ac3f0bad0dd2c013041e Mon Sep 17 00:00:00 2001 From: kikniknik Date: Tue, 28 May 2019 02:09:07 +0300 Subject: [PATCH] Change the way that temperature is retrieved Fixes issue with temperatures < 10. --- check_temp.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/check_temp.sh b/check_temp.sh index 721caa4..0379a16 100755 --- a/check_temp.sh +++ b/check_temp.sh @@ -194,8 +194,9 @@ if [[ -z "$sensor" ]]; then fi -#Get the temperature -TEMP=`${SENSORPROG} | grep "$sensor" | cut -d+ -f2 | cut -c1-2 | head -n1` +# Get the temperature +# Grep the first float with a plus sign and keep only the integer +TEMP=`${SENSORPROG} | grep "$sensor" | head -n1 | grep -o "+[0-9]\+\(.[0-9]\+\)\?" | head -n1 | tr -d '+' | cut -d. -f1` #Old way - Get the temperature #TEMP=`${SENSORPROG} | grep "$sensor" | awk '{print $3}' | cut -c2-3 | head -n1`