osx - Mac OS X Terminal - Display list of File Types from Subfolders -
i have external hard drive has content of recovered drive. folders have 'recup_dir.xx' names , there on thousand.
i have copied on content can think of, of specific file types using:
find . -type f -name \*.jpg -exec cp \{\} /volumes/somedrive/somefolder/ \;
i went through file types can think of - want see file types on drive , in sub folders.
what command can use go through folders , sub folders , display 'total's each file type?
du -hcs
gives total of drive- after total per file type.
can point me in right direction. have thousands of folders , want make sure haven't forgotten file types - want list of them.
thanks in advance.
you can awk (as other scripting languages). here script in awk
:
#!/bin/sh find . -type f -ls | awk ' { type = $11; if ( type ~ /\./ ) { sub(/^.*\./, "", type); } else { type = "."; } sizes[type] += $7; } end { ( type in sizes ) { printf "%10d %s\n", sizes[type], type; } }' | sort -r -n
it uses array sizes
file-suffix index. awk
not have built-in sorting, can piping result through sort
.
Comments
Post a Comment