【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

 

posted @ 2022-02-25 11:15  壹点灵异  阅读(952)  评论(0编辑  收藏  举报