How to make `file` output line break type and encoding for all file types

character encodingnewlinestext;

I often find myself in the need to check the encoding and the line break type of a file.

The file utility seems to be a perfect fit. Unfortunately it doesn't output the desired information for all file types. For example it doesn't do so on .php files.

For example:

file extra.module.php

extra.module.php: PHP script text

But if I rename the file to .txt and remove the PHP starting tag, it outputs both.

file extra.module.txt 

extra.module.txt: UTF-8 Unicode C++ program text, with CRLF line
terminators

I already looked at the manpage and I can use the -i switch to force outputting the character encoding, but there seems to be no switch for the line break type.

Is there a simple solution for this without renaming/changing the file first?

Best Answer

Following @don_crissti's comment, it turns out that passing an empty magicfile to file will make it fall back to detect the default ASCII.

So file -m /dev/null extra.module.php will do the trick in this case and will output the desired

extra.module.php: UTF-8 Unicode C++ program text, with CRLF line terminators