//Find all files of a type and count the size together

This 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}'
By |2008-09-23T23:46:38+01:00September 23rd, 2008|Magic One Liners|0 Comments

About the Author: