Please check this program I am not getting result.
Here sample data:
H124124424 25124 2541
D1254254 2541245 2524 25425 2568
D1254235 2658254 2556 25422 7898
H124124424 25124 2541
Here sample data:
H124124424 25124 2541
D1254254 2541245 2524 25425 2568
D1254235 2658254 2556 25422 7898
H124124424 25124 2541
BEGIN {
if(substr($0,1,1)=="H") {
# do this
#remove first Character
sub( /./, "" )
fh1 = substr($0,2,7)
fh2 = substr($0,9,7)
fh3 = substr($0,16,8)
fh4 = substr($0,24,8)
fh5 = substr($0,32,40)
printf ("%-7s %-7s %-8s %-8s %-40s\n",fh1,fh2,fh3,fh4,fh5 ) > "test.DAT"
} else if(substr($0,1,1)=="D") {
# do this
sub( /./, "" )
fd1 = substr($0,2,8)
fd2 = substr($0,10,8)
fd3 = substr($0,18,4)
fd4 = substr($0,22,15)
# Insert "-" after each group of 5 chars.
gsub( /...../, "&-", fd4 )
# Remove any trailing "-".
sub( /-$/, "", fd4 )
fd5 = substr($0,37,6)
fd6 = substr($0,43,10)
}
}