I have a requirement to insert a dot "." after a position in each line, say 110th position.
For which, I have written the below command.
cat filename | sed 's/./&\./110' > new_filename
The code is working fine, but when we have multi byte (2 or 3) characters in the input file, the insertion of dot is not occurring at 110th location. Is there a way to resolve this issue ?
What operating system and version of sed are you using?
What codeset is being used to encode the multi-byte characters in your input file?
What locale was being used when you ran the command above?
What do you mean by the 110th location? Do you want to insert a period as the 111th character on the line or do you want to insert a period as the 111th byte on the line?
Using cat in this pipeline wastes system resources and slows down your script:
sed 's/./&\./110' < filename > new_filename
but fixing that won't change the problem you are reporting.