//View Tip #173
Similar Tips
» Kill matching processes
» Mass-renaming files
» Randomize lines in a file
» Get your IP address
» Graph connections to hosts

 

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 »




Comments 

Add your comment

Comments are currently disabled
dexpl
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