Reading a file and replacing char by position

Hi
I'm looking for a way to read a text file that may contain 1000 records or more and each of these records has 460 characters. I need to read each record, and add a string of characters starting at position 256 for each record. Any suggestions using UNIX shell scripting.

See if this works for you:

sed 's/.\{255\}/&YourString/' Inp_File

Awesome! Thanks Shell_Life, one thing though as I inserted these 4 characters my data shifted to the right 4 spaces. Anyway to do this without shifting the data over??

You asked to add/insert a string, this way the original data is incremented by the string and thus shifted.

If you do not want to have the data shifted, then you want to replace:

sed 's/\(.\{255\}\)..../\1ABCD/' Inp_File
1 Like

Awesome!!! Thank you very much Shell_Life, that worked like a champ. :b: