#!/bin/bash

# util to output # of files and dirs (loosely, inodes) used
#  per directory, much like du's output.

# (CC BY-SA) 2008 http://creativecommons.org/licenses/by-sa/2.5/ca/
# by Ken Chasse math@sizone.org


find $* -depth | 
  awk -F / '{
              OFS="/";
              NF--;
              for (;NF>0;NF--) { a[$0]++ }
            } 
            END {
              for (b in a) { 
                 printf ("%10s %s\n",a[b],b); 
              }
            }' |
  sort -k1.11 -ru
