I have a file as following:
2300
10 1112221234 111222123420231121PPPPD10+0000000850 ESIM
10 3334446789 333444678920231121PPPPD11+0000000950 RSIM
23
I want the outcome to be as following:
2300
10 1112222345 111222234520231121PPPPD10+0000000850 ESIM
10 3334447890 333444789020231121PPPPD11+0000000950 RSIM
23
I tried with the following code and was able to replace the last 4 digits in the second column and the last 4 digits before the date in the third column. But it also removed extra spaces as well as alphabets/numbers from 11th digit onwards in the third column and got the following:
2300
10 1112222345 1112222345 ESIM
10 3334447890 3334447890 RSIM
23
awk '
BEGIN { FS=OFS=" " }
{if(length($2)>9 && length($3)>9)
{$2 = substr($2,-10)
$3 = substr($3,1,10)
for (i=2;i<=3;i++) {
str = substr($i, 1, length($i) - 4)
for (j = length($i) - 3; j <= length($i); j++) {
str = str (substr($i, j, 1) + 1) % 10
}
$i = str
}
}}
1' filename
If you capture each 'part of interest' from columns $2 and $3, then increment the 4 digits, then use
printfto print the lines, you can get your desired outcome, e.g.