Here's an easy way to identify the files that contain mixed line endings:
cat -A $FILE | grep '^M^M$'
The -A
implies -v
and -E
which includes line endings and other hidden characters. For example, let's create a testfile. I'll use the actual text to represent fairly closely with the line endings you'll see:
$ od -x test1.txt
0000000 6464 2061 0d20 0a0d 6464 6161 2020 0d0d
0000020 0a0a 6164 2020 0a0d
0000030
Now let's see what cat gives us:
$ cat -vE test1.txt
dda ^M^M$
ddaa ^M^M$
$
da ^M$
cat
is indeed showing us the CRs and LFs (though the LFs don't show up on the same line -- and justifiably so), so now we can find them:
find /path -yourPredicatesOfInterest -print | while read fn ; do
cat -A $fn | grep '^M^M$' > /dev/null 2>&1 && echo "$fn contains multiple CR CR LFs"
done
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…