我想遍历所有子目录,除了“node_modules”目录。


当前回答

find . ! -name "node_modules" -type d 

其他回答

步骤1:

vim ~ / . bash_profile

search() {
    grep -InH -r --exclude-dir=*build*  -e "$1" .
}

步骤2:

源~ / . bash_profile

用法:

搜索”< string_to_be_searched >”

你可以试试grep -R搜索。| grep -v '^node_modules/.*'

find . ! -name "node_modules" -type d 

非常有用,特别是对于那些处理Node.js时,我们希望避免在“node_modules”中搜索:

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

一个简单的工作命令:

root/dspace# grep -r --exclude-dir={log,assetstore} "creativecommons.org"

上面我grep文本“creativecommons.org”在当前目录“dspace”和排除dirs{日志,资产存储}。

完成了。