May 29, 2005 #1 MoshiachNow IS-IT--Management Joined Feb 6, 2002 Messages 1,851 Location IL How can one find all dirs that contain more then 1000 files? Thanks Long live king Moshiach ! http://www.7for70.com/
How can one find all dirs that contain more then 1000 files? Thanks Long live king Moshiach ! http://www.7for70.com/
May 30, 2005 1 #2 p5wizard IS-IT--Management Joined Apr 18, 2005 Messages 3,165 Location BE 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 Upvote 0 Downvote
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
May 30, 2005 Thread starter #3 MoshiachNow IS-IT--Management Joined Feb 6, 2002 Messages 1,851 Location IL Thanks,does the trick Long live king Moshiach ! http://www.7for70.com/ Upvote 0 Downvote