• Get the Flash Player to see the slideshow.
  • Categories

  • Authors

  • Great Quotes

    A little less conversation, a little more action please… — Elvis

Get in touch...

To have a chat about
your CMS needs...

Call us 0207 193 2014
or
Email us on

Find all files of a type and count the size together

September 23rd, 2008 by Gavin Colborne

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}'

Leave a Reply

You must be logged in to post a comment.