Last Updated: February 25, 2016
·
808
· harmstyler

Recursively find and replace dos line endings

When working on a project, from time to time it is necessary to convert a file's line endings. dos2unix is a simple tool that will convert dos line ending to unix line endings on a single file. With a little bash magic and a little stack overflow help I was able to build a command that recursively executes the bash2unix command on all files within the current directory, ignoring the git folder if there is one. I hope you find it helpful, I made it an alias called convertdir. Also, git can do this if you clone a git repo, so this is primarily useful when you downloaded the directory without git (e.g. a tarball download from GitHub).

find . -type f \! -path \*/\.git/\* -exec dos2unix {} \;