Wednesday, December 7, 2011

Files in directories

I was playing with some rsync-ing nowdays and somehow there was more files than I was expecting. Tons of files... I was wondering how to find out where are those files in the huge directory structure.

My solution was this:

find -L . -maxdepth 1 -mindepth 1 -type d -exec /bin/bash -c 'echo -n "{} "; find -L {}|wc -l' \; | column -t


It prints the file count of the directoryies where you run.

With the help of this pice of .... hmmm... beauty, I was able to find thousands of files that neadn't to be there.:)

It works like follows:

stone@home:/usr/src/linux-headers-3.0.0-14$ find -L . -maxdepth 1 -mindepth 1 -type d -exec /bin/bash -c 'echo -n "{} "; find -L {}|wc -l' \; | column -t
./kernel 28
./arch 8032
./ubuntu 28
./Documentation 57
./virt 3
./drivers 1673
./tools 51
./ipc 2
./scripts 241
./crypto 6
./include 2670
./usr 3
./security 24
./sound 240
./net 194
./block 4
./firmware 2
./fs 221
./mm 4
./samples 19
./lib 21
./init 3
stone@home:/usr/src/linux-headers-3.0.0-14$