sed pattern matching help required

Hi I am trying to pattern match with sed, if it finds a match I need it to insert characters at the 28th position, its working but its also adding an extra space and I don't know why, below is the code.

sed 's/715023044/\n&/g' $asn | sed '/^71502304413-000/s/./B4/28' | sed -e :a -e '$!N;s/\n//;ta'   > tmp.tmp

Original

71502304413-000                                  00000000000010010000000000000

New

71502304413-000            B4                     0000000000001001000000000000

As you can see on the bottom line it has added an extra space, any ideas?

Regards,

Paul

I can't see it having an extra space. You are replacing ONE arbitrary char by B4 (2 chars), so everything is shifted 1 pos back. What surprises me is that the lines have identical length.

Thanks for the reply,

New to this so never thought of it like that but makes sense, is there anyway to insert at position 28 and overwrite hence not adding an extra character?

Try s/../B4/ , but you may need to play with the 28 (maybe 14?) as I'm not sure what exactly it will count. Or, try s/./B/28;s/./4/29 .

Ok will give it a go and let you know.

Appreciate the help.

---------- Post updated at 05:39 AM ---------- Previous update was at 04:44 AM ----------

Thanks RudiC that helped me a lot!

Much appreciated :b: