Removing ^M from a text file
Do you see ^M at the end of every line? Or ^M at random places where a new line should be?
This seems to happen when a DOS or Windows machine edits a text file. It is the Control Character for Carriage Return. To remove this, you will need to edit the file in Vi. Not sure how to do this in other text editors, but this will definitely work in Vi.
If you want to just remove the ^M characters, run this command in Vi:
s:%/^M//gNOTE: Do not type Shift-6, Shift-m. That will not work. You will need to hold down ctrl while pressing V then M.If you want to replace each ^M character with a new line, run this command in Vi:
s:%/^M/^M/gAgain, hit ctrl-V-M to issue the second ^M in the replacement field.
Done!!
Post a Comment
You must be logged in to post a comment.