Need help in building Unix script

Hi all,
We have a requirement like we need to create a program which will change a particular string in the file. For example

+=KA1238767 1121 3344645 686943 22356
01 567893 12435 12121 983627 121 1092 091217
02 may be for engine failure

In the above file we need to change the bold string to 56789C.
The new file will be as follows

+=KA1238767 1121 3344645 686943 22356
01 56789C 12435 12121 983627 121 1092 091217
02 may be for engine failure

The exact problem is the bold string may vary from time to time. It can be 145629 in that case the string which will be replaced with it is 14562I and so on. In general the last character needs to be changed to the corresponding alphabet. Eg.
1- A
2-B
3-C
4-D
5-E
....
9-I

Any type of suggestion or help will be highly appreciated.
Thank you in advance.

Regards
Susant

csadev:/home/jmcnama> cat filename
example file

+=KA1238767 1121 3344645 686943 22356
01 567893 12435 12121 983627 121 1092 091217
02 may be for engine failure
+=KA1238767 1121 3344645 686943 22356
01 123456 12435 12121 983627 121 1092 091217
02 may be for engine failure
+=KA1238767 1121 3344645 686943 22356
01 567892 12435 12121 983627 121 1092 091217
02 may be for engine failure
+=KA1238767 1121 3344645 686943 22356
01 567898 12435 12121 983627 121 1092 091217
02 may be for engine failure

sample output
csadev:/home/jmcnama> t.awk

+=KA1238767 1121 3344645 686943 22356
01 56789C 12435 12121 983627 121 1092 091217
02 may be for engine failure
+=KA1238767 1121 3344645 686943 22356
01 12345F 12435 12121 983627 121 1092 091217
02 may be for engine failure
+=KA1238767 1121 3344645 686943 22356
01 56789B 12435 12121 983627 121 1092 091217
02 may be for engine failure
+=KA1238767 1121 3344645 686943 22356
01 56789H 12435 12121 983627 121 1092 091217
02 may be for engine failure

awk code
csadev:/home/jmcnama> cat t.awk

awk 'BEGIN { arr["1"]="A";
             arr["2"]="B";
             arr["3"]="C";
             arr["4"]="D";
             arr["5"]="E";
             arr["6"]="F";
             arr["7"]="G";
             arr["8"]="H";
             arr["9"]="I";
           }
    {   if ( $0 ~ /^01/)
        {
          printf("%s %s", $1, substr($2, 1, length($2)-1))
          b=substr($2, length($2))
          printf("%s ", arr )
          for(i=3; i< NF; i++) printf("%s ", $i)
          print $NF
        }
        else
        {
          print $0
        }
    } '  filename

Thank you a lot jim :slight_smile: for the quickest response. I still need to check though.

Regards
Susant