在Linux中,要在find模糊查找时排除特定目录,可以使用-prune选项
find . -type d -name 'node_modules' -prune -o -type f -name '*.js' -print
这个命令的解释如下:
find .:从当前目录开始查找。-type d:只查找目录。-name 'node_modules':查找名为"node_modules"的目录。-prune:当找到匹配的目录时,排除(prune)该目录及其子目录。-o:逻辑或(OR),用于组合多个表达式。-type f:只查找文件。-name '*.js':查找以".js"结尾的文件。-print:打印匹配到的文件路径。这个命令将输出除"node_modules"目录及其子目录之外的所有.js文件。