Finding the size of directory with multiply hardlinked files

Dean S. Messing deanm at sharplabs.com
Sat Mar 15 03:48:25 UTC 2008



Roberto Ragusa wrote:
> Dean S. Messing wrote:
> > Say backup_A was created first.  If I do `du_true
> > backup_A' I shd. see its size.  Now I delete some files
> > in "/dir_to_back_up" and create some other new files.
> > Now I create "backup_B" with the above rsync command.  I'd
> > like for my mythical `du_true' to compute the
> > incremental change in size from backup_A to backup_B.
> 
> du -s -c backup_A backup_B
> 
> I use that to do exactly what you are want (hardlinked backups).
> 
> The first result is the space occupied by A, the second
> result is the _additional_ space occupied by B.
> 
> You can also go beyond two dirs.
> 
> du -s -c backup_A backup_B backup_C backup_D
> 
> But I find this one more useful:
> 
> du -s -c backup_D backup_C backup_B backup_A
> 
> because the result
> 
> 10G backup_D
> 600M backup_C
> 300M backup_B
> 400M backup_A
> 
> tells me that if I delete the oldest backup
> I free 400M, and I can free 700M if I delete
> the two oldest backups, etc.
> 
> You can play with something like:
> 
> du -s -c `ls | sort -r`

Thanks Roberto.  That's _exactly_ what I want.

I saw the -c option of `du' in the man page when
trying to figure this out but it just says

       -c, --total
              produce a grand total

Pray tell, how did you figure this out.
I've re-read the man page and I don't see this
this differential behaviour advertised anywhere.

Dean




More information about the fedora-list mailing list