How can I know if a file is a binary file?
For example, compiled c file.
I want to read all files from some directory, but I want ignore binary files.
grepAssuming binary means file containing non-printable characters (excluding blank characters such as spaces, tabs or new line characters), this may work (both BSD and GNU):
$ grep '[^[:print:][:blank:]]' file && echo Binary || echo Text
Note: GNU grep will report file containing only NULL characters as text, but it would work correctly on BSD version.
For more examples, see: How do I grep for all non-ASCII characters.