Find all files of a type and count the size together
September 23rd, 2008 by Gavin ColborneThis wonderful little tool written by Richard Aldridge uses ’sed’ to group together all the files under a particular folder of a certain type (in the example this is files whose name contains the string ‘local’ but you could easily change this to look for other groups of files such as ‘.log’ or ‘.html’ files) and then adds all their sizes up to give a total number of kb the files amount too.
find . -name '*local*' -ls | awk 'BEGIN {$count=0} /./ {$count += $7} END {print $count}'
