^m in the Linux editor vim to delete the end of a line
Sometimes, when you open a file in Linux that you've edited in Windows, you see ^m characters at the end of the line. It always feels awkward.
The deletion method is as follows:
In the Vim command mode, enter:%s/^m$//g, enter will automatically delete all the ^m characters in the file.
Note: ^m to enter with CTRL + V, CTRL + M, tapping ^ and m directly on the keyboard is no good! The following $ represents the content that matches the end of the line, and the last G indicates that the match in each line is replaced--the global substitution, otherwise only the first match to each row is replaced.
and the script removal method:
Cat File | Col-b > FILE.1//This can be removed, but the characters in the generated file are garbled
Sed-e ' s/.$//g ' File//correct
Sed ' s/^m//' file//correct, but ^m = Ctrl + V, CTRL + M
Appendix: ^m Another scenario is where files are routed through FTP between Windows and Linux systems. This is the recommended method is: Forcibly set the FTP mode for the ASCII way can ah! Of course, it can be done by software Dos2unix. I haven't tried, huh?
Turn: In the Linux VI file in the end of the strange ^m and solve