#!/usr/bin/awk -f # usage: dat2spec_ip.awk file > output #------------------------------------------------------------------------ BEGIN{ i=1 # dummy settings for sensors without IP inclx="999" incly="999" pres ="999" type="" subtype="" } #------------------------------------------------------------------------ # BEGIN AWK MAIN LOOP { if($1=="IDDevice") {dev=$3} if($1=="IDDataType") {type=$3} if($1=="IDDataTypeSub1") {subtype=$3} if($1=="DateTime") {date=$3} if($1=="DateTime") {time=$4} if($1=="IntegrationTime") {it=$3} if($1=="InclX") (inclx=$3) if($1=="InclY") (incly=$3) if($1=="Pressure") (pres=$3) if($1=="PositionLongitude") {long=$3} if($1=="PositionLatitude") {lat=$3} #if(toupper(substr(type,1,8))=="SPECTRUM" && toupper(substr(subtype,1,3))=="RAW") if(toupper(type)=="SPECTRUM" && toupper(subtype)=="RAW") { if ($1==1) { spec_device[i]=dev spec_date[i] =date spec_time[i] =time spec_it[i] =it spec_long[i] =long spec_lat[i] =lat spec_inclx[i] =inclx # resetting for sensors without IP inclx="999" spec_incly[i] =incly incly="999" spec_pres[i] =pres pres ="999" } raw[$1+1,i] = $2 if ($1==255) { i=i+1 } } #END AWK MAIN LOOP } #------------------------------------------------------------------------ END{ for (j=1;j<=i;j++) { printf("%s %s %s %s %s %s %s %s %s",spec_date[j], spec_time[j], spec_device[j], spec_it[j], spec_long[j], spec_lat[j], spec_inclx[j], spec_incly[j], spec_pres[j] ) for (k=1;k<=256;k++) { printf("%s ",raw[k,j]) } printf("\n") } }