Git Bash is a nice bash shell you get in Windows as part of the installation of Git. It comes with other typical unix tools bundled inside, such as grep, sed, awk, perl. It doesn't have the file command.
In this shell, I want to detect files that have DOS-style line endings. I thought this command would work but it doesn't:
grep -l ^M$ *
It doesn't work, even files that don't have CR line endings match. For example if I create 2 sample files
hello.dos, I can confirm with
hello.unix has 6 characters and
hello.dos has 7 characters because of the extra CR, but both files match with
grep. That is:
$ cat hello.* hello hello $ wc hello.* 1 1 7 hello.dos 1 1 6 hello.unix 2 2 13 total $ grep -l ^M hello.* hello.dos hello.unix
Is this a bug in the implementation of
grep in Git Bash?
Is there another way to find all files with DOS-style line endings?