grep only text files

前端 未结 3 826
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-30 19:58
find . -type f | xargs file | grep text | cut -d\':\' -f1 | xargs grep -l \"TEXTSEARCH\" {}

it\'s a good solution? for find TEXTSEARCH recursively in o

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-30 20:22

    Another, less elegant solution than kevs, is, to chain -exec commands in find together, without xargs and cut:

    find . -type f -exec bash -c "file -bi {} | grep -q text" \; -exec grep TEXTSEARCH {} ";" 
    

提交回复
热议问题