This question already has an answer here:

I tried using this:

      $ find . -type f -exec file {} \;
        ./alma: ASCII text
        ./jaj.C: C source, ASCII text
        ./repa: ASCII text, with escape sequences
        ./mas.cpp: C++ source, ASCII text
        ./capa: ASCII text
        ./valami: ASCII text

But if it's a cpp file for example it still writes text so I can't use grep to exclude binary files....what should I do?

share|improve this question

marked as duplicate by AlBlue, greg-449, topher, alexander.polomodov, kamal pal Jun 16 '16 at 10:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
cpp file is a text file, why do you want to exclude it? – Krzysztof Krasoń Jun 16 '16 at 7:00
    
.cpp is text just the same as .c. Why exclude .cpp when you are including .c? – John1024 Jun 16 '16 at 7:02
    
well aren't c and cpp files binary files?I would like to exclude them – Reggie Kapros Jun 16 '16 at 7:08
1  
No, just as file says, they are ASCII text. – John1024 Jun 16 '16 at 7:10
    
@ReggieKapros You can look at the in a text editor and they are readable (non-garbage) – Krzysztof Krasoń Jun 16 '16 at 7:29

Here's the fast method to do it:

find . -type f -exec grep -Iq . {} \; -print

-I in grep will ignore binary files, text files will match right away because of . (any character match), grep will give success for matched file, so -print from find will print the filename.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.