Linux common commands-99: dos2unix

The dos2unix command is used to convert DOS format text files to UNIX format. The text file under DOS uses \r\n as the newline sign, which is represented as 0D 0A in hexadecimal, while the text file under UNIX uses \n as the newline sign, which is represented as 0A in hexadecimal. When copying files from windows system to linux system, the problem of display format often occurs, and the corresponding command is unix2dos .

Syntax format: dos2unix [parameter] [file]

Common parameters:

Example

 # 直接转换格式dos2unix test.py # 多个文件一起转换dos2unix test1.py test2.py test3.py # 转换后生成新的文件,保留原来的文件dos2unix -n oldfile newfile

This article is reprinted from https://xugaoxiang.com/2022/09/07/linux-cmds-99-dos2unix/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment