#!/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 heat, prev total heat, heat diff, # current total volume, prev total volume, volume diff # # the script expects the unit name set as a variable in the awk invocation BEGIN { startflag=0; }; /\/01\/.. 00:01/{ # print if there is a previous element if ( startflag >0 ) { print unitname,$1,$2,lastdate,$3+0,lastheat,$3-lastheat,$4+0,lastvol,$4-lastvol } startflag=1; lastheat=$3+0; lastvol=$4+0; lastdate=$1; }