Re: Finding the size of directory with multiply hardlinked files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Roberto Ragusa wrote:
> Dean Messing wrote:
<snip>
> > 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.
> 
> I just got it by testing and observing results.
> 
> Actually, the "-c" is not needed at all, it's there
> because I also want to know the total space used by backups.
> 
> And... the "-s" is also not needed! It just avoids the
> printing of all the subtotals of the subdirectories of
> your backups.
> 
> It looks like du simply discard everything already
> found on its way when calculating disk space.
> 
> Look at this:
> 
> $ mkdir d
> $ head -c 1000000 /dev/zero >f1
> $ ln d/f1 d/f2
> $ cp d/f1 d/f3
> 
> Now, this command reports only two files and not the third (hardlinked):
> 
> $ du d
> 1962    d
> 
> And, look at this; f2 is totally ignored even if it appears on the
> command line:
> 
> $ du d/f1 d/f2 d/f3
> 981     d/f1
> 981     d/f3
> 
> Amazing.

Indeed!  I just did a bit of testing like yours using multiple directories like this:
(Hope the ascii comes out on your end.)

d1       d2      d3

f1 <--> f1


f2      f2      f2  (d1/d2 and d3/f2 are linked, d2/f2 is a copy).
| <-----------> |

f3      f3 <--> f3



`du' appears (as you implied) to construct a table of what pointer to data
it's seen earlier in the arglist, and just ignore later pointers to the
same data.  As are all good solutions, it's simple and elegant (but
evidently undocumented).  Nice discovery, Roberto.

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux