Dear RudiC,
Thanks a lot for your help, It works perfectly now..
I have modified a little the code to get correct value in indexpoint,
OUT[IX[8]]
..
and i have to remove the tab spaces to let the code works fine.
here the last modification:
read -p " " jd
sed -i -e "s/[[:space:]]\+/ /g" $jd.txt
awk -F: '
BEGIN {FMT = "date +\"%d %d %d %d %11.1f %11.1f %11.1f %d 0%%d%%H%%M%%S %010d %010d\" -d@%s\n"
for (n = split ("Tape_Nb:File_Nb:Line_Name:Point_Number:Cog_Easting:Cog_Northing:Cog_Elevation:Point_Index:Tb_GPS_Time", IX); n>0; n--) SRCH[IX[n]]
}
$1 ~ /^Observer_Report/ {if (flag) printf FMT, OUT[IX[1]], OUT[IX[2]], OUT[IX[3]], OUT[IX[4]],
OUT[IX[5]], OUT[IX[6]], OUT[IX[7]], OUT[IX[8]], from, to, OUT[IX[9]] + 315961200 + 10783 # epoch = GPS + 6.1.1980 + 3h - 17 sec
delete OUT
from = NR
flag = 1
}
{gsub (/[ ]/, _)
to = NR
}
$1 in SRCH {OUT[$1] = $2
}
$1 ~ SRCH[IX[9]] {OUT[$1] = substr($2,1,10)
}
END {printf FMT, OUT[IX[1]], OUT[IX[2]], OUT[IX[3]], OUT[IX[4]],
OUT[IX[5]], OUT[IX[6]], OUT[IX[7]], OUT[IX[8]], from, to, OUT[IX[9]] + 315961200 + 10783 # epoch = GPS + 6.1.1980 + 3h - 17 sec
}
' $jd.txt |
sh |
awk -F[:-\(] '
BEGIN {HD1 = "H26 5678901234567890123456789012345678901234567890123456789012345678901234567890"
HD2 = "H26 1 2 3 4 5 6 7 "
}
NR == 1 {print HD1 RS HD2 > XFILE
print HD1 RS HD2 > SFILE
}
FNR == NR {OR[NR] = $0
MX = NR
next
}
FNR > NXTREP ||
FNR == 1 {n = split (OR[++OCNT], T, " ")
NXTREP = T[n] + 0
printf "S%10.2f%10.2f%3d1 %9.1f%10.1f%6.1f%09d\n", T[3], T[4], T[8], T[5], T[6], T[7], T[9] > SFILE
}
{sub (/^[ ]*/, _)
sub (/ *: */, ":")
}
$1 ~ /^Live_Seis/ {DATA = 1
sub (/Live_Seis[^:]*:/, _)
}
/[^0-9:() -]/ {DATA = 0
}
DATA {printf "X%6d%8d11%10.2f%10.2f%1d%5d%5d1%10.2f%10.2f%10.2f1\n", T[1], T[2], T[3], T[4], T[8], $4, $5, $1, $2, $3 > XFILE
}
' XFILE="$jd.x" SFILE="$jd.s" - $jd.txt
Appreciate your help