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 f
This approach uses same criteria as grep in determining whether a file is binary or text:
is_text_file() {
grep -qI '.' "$1"
}
-q Quiet; Exit immediately with zero status if any match is found-I Process a binary file as if it did not contain matching data'.' match any single character. All files (except an empty file)
will match this pattern.