The ^M character will appear when you open the windows file in the Linux system, although this does not affect the reading, but if you can remove it, it is better, the following small series will introduce you to Linux. How to remove the ^M character in the file.
written on a Windows file, in Linux or Unix open, each line will be out this extra ^ M, but this is different because Windows and * nix line breaks caused us Look at the difference in file format.
View file format under Linux:
# file filename
# 20140304110001.csv: ISO-8859 text //with ^M
# 20140304110002.csv: ISO-8859 text, with CRLF line terminators //with ^M
Files processed under Windows have a CRLF line terminator.
There are several ways to do this:
1. Enter in vi command line mode
:%s/^M$//g # Remove the end of the line ^M .
:%s/^M//g # Remove all ^M.
:%s/^M/[ctrl-v]+[enter]/g # Replace ^M with a carriage return.
:%s/^M/\
/g # Replace ^M with a carriage return.
2. Use the sed command. Similar to the usage of vi:
# sed -e ‘s/^M/\ /g’filename
3. Using the command
Using the dos2unix command, generally The *nix distribution comes with this gadget, which is a Windows-*nix file conversion.
Format: dos2unix filename
Convert multiple files
Format: dos2unix file1 file2 file3 ….
When converting files above, the original file will be modified. Use the -k parameter, or the -n parameter to change the file attributes.
Format: dos2unix -n oldfile newfile //Create a new file, keep the source file unchanged
Format: dos2unix -k filename //Keep the file timestamp unchanged
The same tool provides the *nix - windows file format conversion command: unix2dos, with the same parameters as dos2unix.
*Note: <;^M”, you need to type with Ctrl + V + Ctrl + M instead of the ^+ letter M above the number 6.
The above is the introduction of the ^M character in the contents of the file under Linux. If the ^M character affects your reading, if you want to remove it, just follow the method described in this article. The ^M character was easily removed.
AWK is a regular expression and an important text processing tool. In Linux systems
We all know that the Linux command plus different parameters have different effects. The following s
The current system is basically equipped with the XFS file system. The XFS file sys
The Linux system code reference code repository will become larger and larger durin
The nohup command in the Linux system guide
Linux system grep command operation example summary
How does the Linux system send mail?
Linux method of creating SVN repository through shell scripts
What should I do if the Linux system Git cannot exit completely (exit code 128 or 1)?
How to achieve multi-threaded programming under Linux shell
Red Flag Linux6.0 system to install VirtualBox skills
How to modify the image name in batches under Linux
How does the Win10 system clear the browser cache?
The ultimate optimization of the computer
WP7.8 version of Skype was abandoned, Microsoft turned to support OS X 10.5
What is the command for the Win7 system boot entry?
Where is the Win10 registry? How to open the Win10 registry editor?
Gabriel Aul: The update that cannot be installed currently is not the WP10 preview update
Hi big rush, WP8.1 supports search text SMS
How to make the Win8 system photo application display the picture in the computer