I need to find a sed/awk command which will insert a character at the nth position of a matching string HAVING LENGTH 10. For example, I need to search for the string starting with pattern 541
and having length 10, then insert 9
at the 5th position of that string without replacement, resulting in an 11 character string.
The strings are words separated by white space. Also the pattern will always be at the beginning of the word but there might be multiple matches per line.
Input file:
5414444444 87654873234 88888888888
6646666666 54122222222
54155555558888 54176543235 5416666666
Output file:
54149444444 87654873234 88888888888
6646666666 54122222222
54155555558888 54176543235 54169666666