Currently I am working on a folder of files, and each file have some lines as follows:
abcde fghij
abcde fghij
jklmn pqrst
..... .....
These lines have a specific line length 43. At the middle of each line is a tab character, and at the end is the windows line break character ^M
. I would like to do the following steps:
First, select these lines with line length 43
Second, replace the tab in the middle with a comma
Third, replace the line break character at the end with a dot.
And the expected output should be like this:
abcde, fghij.
abcde, fghij.
jklmn, pqrst.
I have tried sth
as follows, but I failed:
sed -i -e 's/^.\{43\}\r/ ./g' input.file
Does anyone know how to deal with this?
Update You can click this link to get a test file.
^M
or excluding both? – Inian May 07 '19 at 07:32