^M is DOS line break charater which shows up in unix files when uploaded from a windows file system in ascii format.
To remove this, open your file in vi editor and type
:%s/(ctrl-v)(ctrl-m)//g
and press Enter key.
Important!! – press (Ctrl-v) (Ctrl-m) combination to enter ^M character, dont use “^” and M.
If anything goes wrong exit with q!.
I learned this from here.
Very good!
I just encountered this problem and it is so annoying to replace each ^M one by one!
Thank the god here is the solution~
🙂
i love ram\’s!
How can I reverse all the text in a file using vi editor command?
freakin awsome. thank a bunch.
Your substitution command may catch more ^M then necessary. Your file may contain valid ^M in the middle of a line of code for example. Use the following command instead to remove only those at the very end of lines:
:%s/(ctrl-v)(ctrl-m)*$//g
In some flavors of vi (e.g. RedHat), vi does it for you with:
:set fileformat=unix
How to add ^M (Ctrl+V+M) in one particular line in an input file using script? Is it possible to store ^M in a variable?
the simplest way is to use the command dos2unix
how can i remove 200c in vi editor?
how to do this in multiple file , is there a way we can make a program for this
Thanks a lot.. Uploaded a file from excel on to sever box with bunch of ^M
… This post help me…
Thanks
srini
Thank you. It helped me
Thanks guys…this worked for me to remove ^M from my input file. But any idea why this comes when we ftp the a file from windows to UNIX box on ASCII mode?
Thanks guys… It helped me. 🙂
Thanks
I was really pissed off with this ^M in my file,
thanks to Scott i use
:set fileformat=unix
and it works……
@Scott: thanks the “:set fileformat=unix” worked for me on Ubuntu 10.04
thanx alot ..////
This guidance didn’t help me.
However, using “:set fileformat=unix” did.
Thanks!
Thanks a lot….
just use dos2unix that’ll do the work
Thanks.
Thanks a lot!
very helpful.
Use dos2unix command. i.e. to replace all DOS characters to Unix –
$ dos2unix file.c file.c
^M comes from MAC files.
Thanks a lot…!!
Spooled file from Oracle SQL contained ^M at the end of every line along with a carriage return. This tip removed them, which enhanced readability tremendously. Thanks!!!
Pingback: Removendo o caracter ^M com o VIM | ATALIBA TEIXEIRA
Reblogged this on Infornética.
thank you …..good info….
fyuhhhh.. thanks God I found this link..
I need to overtime until 4.00 to find the root cause, and it’s because stubborn ^M…. damn 🙂
THANK YOU!!!!!!!!!!!!!!!! 🙂
:g/^V^M/s// /g
it worked for me
Thanks
Is there any way to transfer a file from windows to unix without getting ^M characters
to send from windows, copy it into notepad first, or use the ‘Paste As’ command, and select plain text. (I dont think you can ‘paste as’ directly into notepad)
thanks!
You can definitely see your enthusiasm within the article you write.
The arena hopes for even more passionate writers such as you who aren’t afraid to mention how they believe. All the time go after your heart.
of course lik your weeb site but you need to check tthe spelling on several of your posts.
Several of them are rife with spelling problems and I find it very troublesome to tell the
truth then again I’ll definitely come again again.
Thanks so much for sharing all with the awesome info! I am looking forward to checking out far more posts! dccfacefkdbg
Pingback: Borrar retornos de carro con vi | tikismikis.org