When configuring the linux dns server today, it is very troublesome to modify the configuration file in linux, so I want to take the configuration file to windows and apply it to linux. After I modify the configuration file in linux through a text document, upload it to linux and run the cat command to view the file...
When configuring the linux dns server today, it is very troublesome to modify the configuration file in linux, so I want to take the configuration file to windows and apply it to linux. When I modified the configuration file in linux through a text document and uploaded it to linux and run the cat command to view it, I found that each line had a ^ M character at the end, so I had to use vi to open it again, delete a row.
Later, I checked the information and found out that it was caused by the different broken line characters between dos and linux, thus providing a better solution. For more information, see the following description.
In linux, we can use the cat command to view the windows system resume text file, but we will find that the dos disconnection line character is ^ M, we become CR and LF. Linux only has LF ($ ). In this case, a CR (^ M) symbol is added. If it is a shell script file, it cannot be executed normally.
In the past, we used to delete a row in vi. Is there a good solution! You may want to convert the format to linux. let's take a look at it. In fact, just a few simple commands.
# Dos2unix [-kn] file [newfile]
# UNIX2dos [-kn] file [newfile]
Parameter parsing
-K: retain the original mtime format of the file (the last modification time of the file content is not updated)
-N: retain the original old file and output the converted content to the new file, for example, dos2UNIX-n old new
EG:
# UNIX2dos-k man. config
# Dos2UNIX-k-n man. config man. config. linux
This is simple, so when copying plain text files between different systems, remember to use UNIX2dos or the dos2UNIX command to convert the broken line format
Author: "New network subnet"