March 20, 2012

Find files with Windows line endings

Just a quickie with some bash magic... I wanted to eliminate mixed and windows line endings from my source files, and after some research and development I got this command line:

find . -not -name *.svn-base -exec grep -Ils $'\r$' {} \;

You must love bash and all of these amazing you-can-do-anything commands. Just takes some time to learn them, and to be able to use them without heavy googling.


  1. Note, if you don't use SVN like I did, it's a bit simpler:

    find . -type f -exec grep -Ils $'\r$' {} \;

  2. ... and if you use git:

    find . -type f -not -path './.git/*' -exec grep -Ils $'\r$' {} \;