Linux command: How to 'find' only text files?

前端 未结 16 882
孤街浪徒
孤街浪徒 2020-12-02 04:43

After a few searches from Google, what I come up with is:

find my_folder -type f -exec grep -l \"needle text\" {} \\; -exec file {} \\; | grep text
         


        
16条回答
  •  渐次进展
    2020-12-02 05:06

    find . -type f | xargs file | grep "ASCII text" | awk -F: '{print $1}'
    

    Use find command to list all files, use file command to verify they are text (not tar,key), finally use awk command to filter and print the result.

提交回复
热议问题