#!/usr/bin/awk -f # # Extract the readings of the log files for the 1st of each month, and # add the previous' month consumption in heat and volume at the end # of the line. The outout contains following entries: # latest unitname, reading date, latest reading time, prev reading date, # current total kWh, prev total kWh, kWh diff # # the script expects the unit name set as a variable in the awk invocation BEGIN { startflag=0; }; /\/01\/.. 00:00/{ # print if there is a previous element if ( startflag >0 ) { print unitname,$1,$2,lastdate,$3+0,lastkWh,$3-lastkWh } startflag=1; lastkWh=$3+0; lastdate=$1; }