If this requires a single sed
command, without using dos2unix
, which modifies the source file in place, you can do something like this (GNU sed may be required)
sed -E 's/\.(^M?)/\1/' testfile
If you type ^M
on the command line as Ctrl + V , then Ctrl + M.
This will remove the '.', Optionally followed by a carriage return character, and replace CR if it was in the original.
source share