The latest tool unix2dos for batch file format conversion in CentOS
Installation:
Yum install dos2unix unix2dos
Ubuntu is different. It seems like this: $ sudo aptitude install tofrodos
Unix2dos corresponds to todos dos2unix and fromdos
Option and parameter:-k: Retain the original mtime format of the file (the last modified time of the file is not updated)
-N: Retain the original file and output the converted content to the new file, for example, dos2unix-n old new
Example: 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.
Format: dos2unix file
2. One-time conversion of multiple file formats:
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 transformation.