How can I exclude directories from grep -R?

前端 未结 13 2158
感动是毒
感动是毒 2020-12-04 04:11

I want to traverse all subdirectories, except the \"node_modules\" directory.

13条回答
  •  死守一世寂寞
    2020-12-04 04:51

    Very useful, especially for those dealing with Node.js where we want to avoid searching inside "node_modules":

    find ./ -not -path "*/node_modules/*" -name "*.js" | xargs grep keyword
    

提交回复
热议问题