How to replace n characters from mth position

April 8, 2011 at 03:37:48
Specs: Unix, HP
I am trying to replace n characters from mth position from a flat file in Unix.

See More: How to replace n characters from mth position

Report •

#1
April 10, 2011 at 10:53:20
I have always solved this problem with a brute force method: cut the string into 3 equal parts: 1 to m, m to n, n to the end-of-line. Then, change the m to n string to whatever is required, and, finally, glue the strings back together.

A Regular Expression solution is available, but it's rather involved requiring a scripting language such as perl.

Check out this link for both solutions:

http://www.computing.net/answers/un...


Report •
Related Solutions


Ask Question