Answer the question
In order to leave comments, you need to log in
How to remove the character "^M" from mysql?
I am uploading Perl clients from mysql to a file under Linux.
I open the file, in it "^M" gets out anywhere.
Just remove these characters, such as col -bx < dosfile > newfile
not kosher - the information has moved to another line, but you need to save the structure. You can handle it, of course, but it's not sporty.
It is necessary to somehow fix these characters in the database itself. Has anyone stumbled upon this before?
Answer the question
In order to leave comments, you need to log in
“the information has moved to another line, but you need to save the structure”
Your case is this:
^M is (most likely) \r (Carriage return), this is a sign of a new line, there are 3 signs of a new line in total: \r (Mac), \ r\n (Win), \n (*nix).
If you really don't like \r use:
dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_replace
perl -p -i -e 's/^M//g' dosfile
only here is the trick to enter the ^M character, you need to press the Ctrl key and hold it down and press v and m, you should get the ^M character
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question