【SHELL】查找包含指定字符串的目录、在找出的路径中找出指定格式的文件、并统计出数量


查找包含字符串“skull”的目录、在找出的路径中找出格式“.c/.cpp/.h”的文件、并统计出数量

find . -path ./out -prune -o -iname "skull" -print | xargs -I % find % -iname *.[c,cpp,h] | wc -l

 

命令分拆解析

查找包含字符串“skull”的目录,且排除在/out路径下查找

find . -path ./out -prune -o -iname "skull" -print

 排除多个目录

find . \( -path ./out -o -path ./vendor \) -prune -o -iname "skull" -print

 

查找包含字符串“skull”的目录、并统计出文件和文件夹数量

find . -path ./out -prune -o -iname "skull" -print | xargs -I % ls -lR % | grep "^-" |  wc -l
find . -path ./out -prune -o -iname "skull" -print | xargs -I % ls -lR % | grep "^d" |  wc -l

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM