BEGIN { FS=" "; x=0; r=1; printf("\n\nRoute %02d Falk_%02d---------\n",r,r); printf(" Breite"); printf(" Länge Kurs km\n"); } { # Process only lines with coordinates if($8!="") { x=x+1; if(x % 29 == 0) { # Start new route # Take time as waypoint name gsub(":","",$1); printf("%02d%-4.4s ",x%100,$1); # Take two or three fields as description if($3=="-") { printf("%-26.26s ",$4 " " $5); } else { printf("%-26.26s ",$3 " " $4 " " $5); } # Calculate coordinates lon=substr($8,2,6); long=lon/10000; lonm=(lon/100)%100; lons=lon%100; lat=substr($8,9,6); latg=lat/10000; latm=(lat/100)%100; lats=lat%100; # Write coordinates printf("N %02ld°%02ld'%02ld.0 ",latg,latm,lats); printf("E%03ld°%02ld'%02ld.0 ",long,lonm,lons); # Finish line printf(" 0° 0,0\n"); printf(" Summ 0,0\n"); printf(" Direct 0° 0,0\n"); r=r+1; printf("\n\nRoute %02d Falk_%02d---------\n",r,r); printf(" Breite"); printf(" Länge Kurs km\n"); } # Take time as waypoint name gsub(":","",$1); printf("%02d%-4.4s ",x%100,$1); # Take two or three fields as description if($3=="-") { printf("%-26.26s ",$4 " " $5); } else { printf("%-26.26s ",$3 " " $4 " " $5); } # Calculate coordinates lon=substr($8,2,6); long=lon/10000; lonm=(lon/100)%100; lons=lon%100; lat=substr($8,9,6); latg=lat/10000; latm=(lat/100)%100; lats=lat%100; # Write coordinates printf("N %02ld°%02ld'%02ld.0 ",latg,latm,lats); printf("E%03ld°%02ld'%02ld.0 ",long,lonm,lons); # Finish line printf(" 0° 0,0\n"); } } END { printf(" Summ 0,0\n"); printf(" Direct 0° 0,0\n"); }