//View Tip #173
Similar Tips
» Remove DS_Store files from shared folders
» Version all unversioned files in an SVN checkout
» Remove empty directories
» Sorting debian packages installed by size
» Print first line of every paragraph


Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
To find out the number of files of each type in your current directory try the following:

find ${*-.} -type f | xargs file | awk -F, '{print $1}' | awk '{$1=NULL;print $0}' | sort | uniq -c | sort -nr  

5 PHP script text 2 data 2 Zip archive data 2 GIF image data 1 PNG image data

(You may want to add this as an alias rather than type it in each time!)

View Comments »


Add your comment

Comments are currently disabled
If file names contain whitespace characters you can use

find ${*-.} -type f -print0 | xargs -0 file

instead of

find ${*-.} -type f | xargs file
Posted 2010-02-27 13:51:28

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit