DOS and linux line breaks

Source: Internet
Author: User
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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.