Find control m characters and remove it

前端 未结 2 857
时光取名叫无心
时光取名叫无心 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:07

    Use find with sed.

    With GNU sed:

    find . -name "*ctl" -type f -exec sed -i 's,^M,,' "{}" \;
    

    With BSD sed:

    find . -name "*ctl" -type f -exec sed -i '' -e 's,^M,,' "{}" \;
    

    ^M in sed argument is a literal Control-M, not ASCII ^ followed M. Press Control-v and then M to enter it.

提交回复
热议问题