Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find dirs with more then 1000 files 1

Status
Not open for further replies.
quick and dirty: find all dirs, ls -l every dir and count files.

Code:
find / -type d|while read dir
do
 count=$(ls -l ${dir}|grep -c '^-')
 if [ ${count} -gt 1000 ]
 then
  echo "${dir}: ${count} files"
 fi
done

but it's going to take some time (and disk I/Os).

I guess a script (perl or awk anyone?) could be written that analyses a

find / -ls

output and counts files in dirs by looking at the 'd' or '-' in the first position and comparing the 'dir' part of pathnames in the last field...


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top