D
D
Dj_PiTeR_FM2012-07-26 11:12:06
Perl
Dj_PiTeR_FM, 2012-07-26 11:12:06

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 > newfilenot 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

5 answer(s)
K
Konstantin, 2012-07-26
@Dj_PiTeR_FM

“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

A
asterisk, 2012-07-26
@asterisk

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

D
Dj_PiTeR_FM, 2012-07-26
@Dj_PiTeR_FM

Why was this downvoted? Didn't understand?

E
eaa, 2012-07-26
@eaa

And you will replace all \r with a space - here you will have one line.

E
ergil, 2012-07-26
@ergil

call dos2unix from perl ;)
there is such a package in all distributions, just to remove the wrong newline, usually shown as ^M

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question