thanks for helping out!
I want a shell script to read the last value from a txt file. I've got this (another script) working from a python script, but this does not work in a shell script. I found some helping script parts here and there (on stackoverflow) Bu I cant get this to work.
How can I read the last value form a txt file (temper.txt) in to the shell script?
txt file:
1
2
3
4
5
6
7
Shell script:
#!/bin/bash
# Domoticz server
SERVER="192.168.0.30:8080"
# IDX DHT
# The number of the IDX in the list of peripherals
DHTIDX="1"
# temp file with the counting
TMPFILE="/var/tmp/temper.txt"
# old piece of the script. not used
#sudo nice -20 Adafruit_DHT 2302 $DHTPIN > $TMPFILE
# 5 seconds for testing
sleep 5
# piece of the script where I want to read the last value form the TEMPFILE!
PULS=$(cat $TMPFILE|grep .... last value... |awk '.... last value ....' |sed -r 's/^.*=//' | sed -r 's/\*//')
echo "PULS: $PULS"
# send data
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command¶m=udevice&idx=$DHTIDX&nvalue=0&svalue=$PULS"
PULS=""
#rm $TMPFILE
exit 0
fi
echo "CPT: $cpt"
cpt=$(($cpt+1))
done
exit 1