59 words
1 minute

Removing ^M Line Endings from Multiple Files

2022-11-19
Views —

Files copied directly from Windows to Linux or macOS may show ^M at the ends of lines in git diff. Windows line endings use two characters, \r\n.

Install dos2unix#

Ubuntu or Debian:

sudo apt-get install dos2unix

CentOS:

sudo yum install dos2unix

macOS:

brew install dos2unix

Convert one file#

dos2unix filename

Convert multiple files#

The original example finds Lua files and passes them to dos2unix:

find ./ -name *.lua | xargs dos2unix
Removing ^M Line Endings from Multiple Files
https://blog.coding1024.com/en/posts/5dcaa2e/
Author
huangjx
Published at
2022-11-19
License
CC BY-NC-SA 4.0

Comments

Questions, ideas and experiences are welcome. Please be kind and avoid sharing private information.

Loading comments…