First let me explain the three different types of line break/newline/line ending/line termination types.
There is carriage return with the escape sequence \r
with hexadecimal code value 0D
abbreviated with CR and line-feed with the escape sequence \n
with hexadecimal code value 0A
abbreviated with LF.
- Text files on MS-DOS/Windows use CR+LF as newline.
- Text files on Unix/Linux/MAC (since OS X) use just LF as newline.
- Text files on MAC before OS X use just CR as newline.
So I suppose in real the task is to insert after tilde not just a carriage return, but a carriage return + line-feed.
The answers on How can you find and replace text in a file using the Windows command-line environment? offer many solutions for replacing strings in text files using Windows command line.
The first suggested solution is with using JREPL.BAT written by Dave Benham.
jrepl.bat "~" "~\r\n" /X /F "FileToModify.txt" /O -
This solution works for a text file containing the posted line and produce the expected output.