How to determine the line ending of a file

line-endings, scripting

Solution

You could use grep

egrep -l $'\r'\$ *

Problem

I have a bunch (hundreds) of files that are supposed to have Unix line endings. I strongly suspect that some of them have Windows line endings, and I want to programmatically figure out which ones do. I know I can just run ``` flip -u ``` or something similar in a script to convert everything, but I want to be able to identify those files that need changing first.

Original source