How to find binary files in a directory?

This finds all non-text based, binary, and empty files.

Edit

Solution with only grep (from Mehrdad’s comment):

grep -rIL .

Original answer

This does not require any other tool except find and grep:

find . -type f -exec grep -IL . "{}" \;

-I tells grep to assume binary files as unmatched

-L prints only unmatched files

. matches anything else


Edit 2

This finds all non-empty binary files:

find . -type f ! -size 0 -exec grep -IL . "{}" \;

Leave a Comment