Quote:
R V1.0 2001-10-13 11:56:11 C
1 0012.68
1 0012.68
1 0012.75
... (it keeps outputing the temperature until you stop reading
So my shell script uses "head" to grab the first three lines of the output of the serial port. It then uses "tail" to grab the last line of the three.
...
Quote:
1268
0
0
0
Okay, so not overly simplified, but this version handles temperatures that have more/fewer leading zeros.
awk '/^1 /{ if (++i == 2) {print gensub("^0*","","g",gensub("[.]","",1,$2)) "\n0\n0\n0";exit}}'
In multi-line format, it's easier to read (or would be, if the BBS could use a proper fixed font for code display!):Code:
awk '
/^1 /{
if (++i == 2) {
tmp = gensub("[.]","",1,$2)
gsub("^0*","",tmp)
print tmp "\n0\n0\n0"
exit
}
}'