参考 https://www.jianshu.com/p/e0a9fb35601a
发现描述基本没问题,使用上还有些差异,特此记录一下:
<以下主要是 -prune -o -print 三者叠加情况的过滤实践 >
test-1:
date; mx=2; find . -maxdepth $mx -type d -path "./.git" -prune -o -path "./.repo" -prune -o -path "./out" -prune -o -type f -name "*akefile*" -print
2023年 09月 20日 星期三 13:34:05 CST
./kernel/Makefile
./u-boot/Makefile
./Makefile
test-2:
$ date; mx=2; find . -maxdepth $mx -type d -path "./.git" -prune -o -path "./.repo" -prune -o -path "./out" -prune -o -wholename "./Makefile" -prune -o -type f -name "*akefile*" -print
2023年 09月 20日 星期三 13:36:21 CST
./kernel/Makefile
./u-boot/Makefile
test-3:
$ date; ex=;mx=2; find . -maxdepth $mx -type d -path "./.git" -prune -o -path "./.repo" -prune -o -path "./out" -prune -o -wholename "./Makefile" -prune -o -type f -name "*akefile*"
2023年 09月 20日 星期三 13:37:15 CST
./kernel/Makefile
./out
./u-boot/Makefile
./Makefile
./.git
PS: -o 理论上和shell的或||等价,但又不太一致,它在find的输出中也有与的成分存在,有print参数存在时会优先被print与掉。