Bash copy and paste text in file from one position to another

Hi I have a text file with lines beginning with 71303, 71403, 71602,

I need to copy the 10 digit text at position 30 on lines beginning with 71303 (5500011446) to position 99 on every line beginning with 71602 (see example below),

There may be many 71303 lines but I need the text copying to the next 71602 line it finds then move on to the next 71303 in the file and again copy the text at position 30 to the next 71602 line at position 99

From this:

7130300404585171115LN   03    5500011446        LN                    W444B    71403CPLA27826AA             K0231AA/5             0060000000026000ST0000000026000ST000  001                S        G              
71602                                                                                                        

so that it looks like this:

7130300404585171115LN   03    5500011446        LN                   W444B    71403CPLA27826AA             K0231AA/5              0060000000026000ST0000000026000ST000  001                S        G             
71602                                                                                              5500011446

Hope this makes sense and thank you in advance for any help.

Any attempts / ideas / thoughts from your side?

Hello firefox2k2,

I have a few to questions pose in response first:-

  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)

Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.

We're all here to learn and getting the relevant information will help us all.

kind regards,
Robin