If I open files I created in Windows, the lines all end with ^M
.
How do I delete these characters all at once?
相关问题
- Is shmid returned by shmget() unique across proces
- What is the best way to do a search in a large fil
- how to get running process information in java?
- Spring Integration - Inbound file endpoint. How to
- Error building gcc 4.8.3 from source: libstdc++.so
I knew I'd seen this somewhere. Here is the FreeBSD login tip:
Need to remove all those ^M characters from a DOS file? Try
:set fileformat=unix
to convert from dos to unix.below command is used for reformat all .sh file in current directory, I tested it on my Fedora OS.
I wanted newlines in place of the ^M's. Perl to the rescue:
Or to write to stdout:
I prefer to use the following command :
You can also use
mac
ordos
to respectively convert your file to macintosh or MS-DOS/MS-Windows file convention. And it does nothing if the file is already in the correct format.For more information, see the vim help :
from: http://vim.wikia.com/wiki/Change_end-of-line_format_for_dos-mac-unix
[Esc] :%s/\r$//