Linux 4 All

Best Linux tricks source

Sometimes you need to identify folders with largest number of files. To get a top 50, you can use 2 methods.

Method 1:

for i in `find $DIRECTORY -type d`; do echo `ls -Al $i | wc -l` $i; done | sort -nr | head -50

Method 2:

locate $DIRECTORY | cut -d `/` -f 1-6 | uniq -c locate / | cut -d `/`-f 1-6 | uniq -c | sort -nr | head -50

Perhaps you should run updatedb before using second method.

Top 10 memory consuming processes arrow-right
Next post

arrow-left Fastest way to clear a folder with huge number of files
Previous post

Leave a Reply

Your email address will not be published. Required fields are marked *