I would like to find out which of my files in a directory are dos text files (as opposed to unix text files).
What I've tried:
find . -name "*.php" | xargs grep ^M -l
It's not giving me reliable results... so I'm looking for a better alternative.
Any suggestions, ideas?
Thanks
Clarification
In addition to what I've said above, the problem is that i have a bunch of dos files with no ^M characters in them (hence my note about reliability).
The way i currently determine whether a file is dos or not is through Vim, where at the bottom it says:
"filename.php" [dos] [noeol]
If file reports "CRLF line terminators", the file is DOS-style. If file reports "CR line terminators", the file is Mac-style. If file doesn't mention line terminators, the file is Unix-style.
DOS format uses "carriage return" (CR or \r ) then "line feed" (LF or \n ). Mac format uses "carriage return" (CR or \r ) Unix uses "line feed" (LF or \n )
(1) A computer file created by an application running under the DOS operating system. See DOS. (2) A text file. See ASCII file.
How about:
find . -name "*.php" | xargs file | grep "CRLF"
I don't think it is reliable to try and use ^M
to try and find the files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With