Linux Command dos2unix Analysis

Source: Internet
Author: User


Linux Command dos2unix analysis the purpose of this command is as follows: The dos2unix command is used to convert a text file in DOS format to a UNIX format (DOS/MAC to UNIX text fileformat converter ). The text file in DOS uses \ r \ n as the line break Mark, which indicates that the hexadecimal format is 0D0A. The Unix text file uses \ n as the line break sign, which indicates that the hexadecimal format is 0A.

In Linux, when a text file in DOS format is opened with a lower version of vi, ^ M is displayed at the end of the line, and many commands cannot properly process the file in this format, A shell script. In Windows, Unix text files are displayed together when they are opened with Notepad. Therefore, two formats of files are required to convert each other. The unix2dos command is used to convert UNIX format text files to DOS format.
1. All files are converted from dos to unix. In a unix system, you can view the converted file format by using the file name. Www.2cto.com format: dos2unix file 2. One-time conversion of multiple files format: Format: dos2unix file1 file2 file3
3. During the above conversion, it will be directly modified on the original file. If you want to save the Conversion Result to another file without changing the source file, you can use the-n parameter. Format: dos2unix-n oldfile newfile
4. If you want to keep the file timestamp unchanged, add the-k parameter. Therefore, you can add the-k parameter to the preceding commands to keep the file timestamp. Format: dos2unix-k file format: dos2unix-k file1 file2 file3
If it is a script file generated under Windows, it cannot be run directly after it is uploaded to unix, and you need to run the above command to complete the file format change. [/Size] [size = large] [size = xx-large] [/size]
 

Related Article

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.