I would like to cut 150.8
from this string temp1: +150.8°F (crit = +197.6°F)
. Here is my script for logging temperatures with the command sensors
:
#!/bin/bash
now=$(date +"%m_%d_%Y") # get current date
now_excel=$(date +"%D %H:%M") # get current date & time in excel format
file_dir="/var/www/html/logs"
file="$file_dir/logging_$now.csv" # backup name and directory
temp=$(sensors -Af | sed -n '2{p;q}') # temp1: +150.8°F (crit = +197.6°F)
#temp_num="$temp" | sed 's/+\(.*\)°/\1/g'
# add line to csv
printf "$now_excel" >> "$file"
printf ", " >> "$file"
printf "$temp" >> "$file"
printf "\n" >> "$file"
find "$file_dir"/* -mtime +3 -exec rm {} \; # remove any backup files older than 3 days
exit 0