I have a file with records which are nearly 500 characters long, fields are separated by the pipe character (|). I need to perform a substitution on characters at positions 417 - 421. Unfortunately there will not be any unique string here which I can substitute.
I know I could for example do something like:
's/^....... [417 times]/&UNIQUE_CHAR/'
and then use the UNIQUE_CHAR to help me confidently change the chars I want to.
But there must be a more elegant way of doing this.
I also know I can do something like 's/^.* ' to identify any character repeated any number of times. Is there any way to identify any character repeated 417 times? That would help.
Or perhaps there's a better way - I expect there is. Perhaps I shouldn't be using sed but that's what I feel most comfortable with. I don't want to write a C program or use PERL (because I don't know PERL & won't easily be able to maintain the program).
Just to help illustrate the problem. My file could look like:
| field 1| field2|field 3| x| another field|
| field 1| field2|field 3| z| another field|
What I want to change are the x & z - but in my case they are in char positions 417 - 421.
Hope this makes sense & that someone can help!
Thanks, Chris
I know I could for example do something like:
's/^....... [417 times]/&UNIQUE_CHAR/'
and then use the UNIQUE_CHAR to help me confidently change the chars I want to.
But there must be a more elegant way of doing this.
I also know I can do something like 's/^.* ' to identify any character repeated any number of times. Is there any way to identify any character repeated 417 times? That would help.
Or perhaps there's a better way - I expect there is. Perhaps I shouldn't be using sed but that's what I feel most comfortable with. I don't want to write a C program or use PERL (because I don't know PERL & won't easily be able to maintain the program).
Just to help illustrate the problem. My file could look like:
| field 1| field2|field 3| x| another field|
| field 1| field2|field 3| z| another field|
What I want to change are the x & z - but in my case they are in char positions 417 - 421.
Hope this makes sense & that someone can help!
Thanks, Chris