TXR:
@(bind idtab @(relate '("radeon" "k10temp")
'("GPU" "CPU")
"SYS"))
@(bind thash @(hash))
@(repeat)
@id-@bus-@code
Adapter: @name
@ (repeat)
temp@num: @{temp}°C@nil
@ (do (set [thash `@[idtab id]_@num`] temp))
@ (until)
@ (end)
@(end)
@(do (dohash (tag temp thash)
(sh `echo gmetric -t uint16 -u Celsius -n @tag -v @temp`)))
$ txr temp.txr temp.dat
gmetric -t uint16 -u Celsius -n SYS_2 -v +43.0
gmetric -t uint16 -u Celsius -n SYS_1 -v +31.0
gmetric -t uint16 -u Celsius -n CPU_1 -v +36.8
gmetric -t uint16 -u Celsius -n GPU_1 -v +50.5
gmetric -t uint16 -u Celsius -n SYS_3 -v +38.0
That's based on what I think the Awk is stuffing into the associative array. I was not able to run the code as pasted verbatim from the site: $ gawk -f temp.awk temp.dat
gawk: temp.awk:32: temp = substr(
gawk: temp.awk:32: ^ unexpected newline or end of string
gawk: temp.awk:35: matches[1, "length"]
gawk: temp.awk:35: ^ unexpected newline or end of string
gawk: temp.awk:35: );
gawk: temp.awk:35: ^ 0 is invalid as number of arguments for substr
$ mawk -f temp.awk temp.dat
mawk: temp.awk: line 30: regular expression compile failed (missing operand)
+([0-9.]+)°C
mawk: temp.awk: line 30: syntax error at or near ,
mawk: temp.awk: line 31: missing ) near end of line
mawk: temp.awk: line 32: syntax error at or near ,
mawk: temp.awk: line 35: extra ')'
I suspect the author may have tweaked the code for presentation in the blog without rechecking that it still works. Or else it needs some specific implementation and version of awk, with specific command line arguments that are not given, unfortunately.