Problem :
I created a .txt file on Win 8 [using sublime] (with copied text for here) and moved it to my VM running Linux.
I used cat tmp.txt >> .bashrc
to append those lines into .bashrc but mysterious ^M
were added in the end of every line (I noticed after sourch .bashrc
failed).
I removed those and now it’s fine, but where did they come from?
Solution :
Simple…
On Windows end-of-line is actually handled with 2 characters: ˆM (Carriage Return) and ˆJ (Line-Feed).
Unix-like systems, like Linux, only use ˆJ.
You save the file on Windows and Linux shows you the ˆM as a normal character.
I never used Sublime, but it probably has an option to convert between the 2 formats so you can just save the file in Unix format from Sublime.
(In fact: most text/programmers-editors have such options.)