Find control m characters and remove it

前端 未结 2 854
时光取名叫无心
时光取名叫无心 2020-12-22 13:54

Is there is any single line command to recursively find the .ctl file in all the directories and remove the control m characters from it?

2条回答
  •  北海茫月
    2020-12-22 14:20

    dos2unix was born to solve this problem.

    You can locate all the target files by find or whatever program, then

    dos2unix filename
    

    Background of this problem (by Dominique )

    Let's explain what this is about: in UNIX, ENTER is translated as chr(13) (ASCII-code of carriage return), in DOS (Windows) ENTER is translated as chr(13)+chr(10) (carriage return combined with newline character). When you open a Windows textfile in UNIX, you see that chr(10) character (which you don't want). The mentioned dos2unix command searches for that chr(13)+chr(10) and removes the chr(10) characters. – Dominique

提交回复
热议问题