{ if(NR <= 5){ # strip out the first 5 header lines without touching them - will put them back later print > "header"; } else { # check not the last line of the file if(substr($0,1,5) != "[END]"){ # otherwise extract the date+time and convert to a Unix timestamp timestr = sprintf("%4d %02d %02d %02d %02d %02d 0",substr($1,7,4),substr($1,1,2),substr($1,4,2),substr($1,12,2),substr($1,15,2),substr($1,18,2)); timecount = mktime(timestr); # output the timestamp at start of the line printf("%d ",timecount); # now output all the other fields - have a trap for empty field which will be filled with -999.999 for (i=2;i<=NF;i++){ if($i == ""){ printf(" %9.3f",-999.999); }else{ printf(" %9.3f",$i); } } # now give a Unix line ending printf("\n"); } } }