Posted 07.14.2009 by Jack
Today I used the Windows Notepad to save a text file onto my Debian server, thinking that I'd be able to view it easily using vi. But when I tried to do so, every line ended with an "^M". Those "^M"s are newline characters. Windows and Linux use different newline characters, so in order to have a Windows text document display properly in Linux, some conversion is needed. I used the handy tr command like so:
0 jack@srv-01:~$ cat text_windows.txt | tr -d \\r > text_unix.txt
And now the "^M"s are gone! Of course, text_unix.txt now looks funky in Windows, but for my purposes that's just fine; you could always save a Windows version and a Linux version if you'll need to view your file from both operating systems.