I'm having issues with line endings. I have a file tracked by git. Then I'm trying to recreate that file with PowerShell with $content | Out-File $location
and git is tracking a change in the line ending at EOF.
If in the terminal I run file ./somefile.sql
(the file already in git)
I get an output ./somefile.sql ASCII text, with CRLF line terminators
Running cat -ve ./somefile.sql
The last 2 lines of the file shows
^M$
END^M$ #'END' is actual text in the file
If in the terminal I run file ./dupfile.sql
(the file created by PowerShell)
I get an output ./dupfile.sql ASCII text, with CRLF, LF line terminators
Running cat -ve ./dupfile.sql
The last 2 lines of the file shows
^M$
END$
If I change Out-File to use $content | Out-File $location -NoNewLine
and check the dupfile
outputs again I get:
ASCII text, with CRLF line terminators
...but...
^M$
END%
How can I use Out-File
to write $content
and get a ^M$
ending like the one I have in git?