How to tell binary from text files in linux

Posted by gabor on Stack Overflow See other posts from Stack Overflow or by gabor
Published on 2010-04-15T11:53:54Z Indexed on 2010/04/15 12:13 UTC
Read the original article Hit count: 298

Filed under:
|
|
|

The linux file command does a very good job in recognising file types and gives very fine-grained results. The diff tool is able to tell binary files from text files, producing a different output.

Is there a way to tell binary files form text files? All I want is a yes/no answer whether a given file is binary. Because it's difficult to define binary, let's say I want to know if diff will attempt a text-based comparison.

To clarify the question: I do not care if it's ASCII text or XML as long as it's text. Also, I do not want to differentiate between MP3 and JPEG files, as they're all binary.

© Stack Overflow or respective owner

Related posts about linux

Related posts about diff