[clug] Disk vs file size
Andrew Janke
a.janke at gmail.com
Thu Aug 8 11:56:32 UTC 2019
> > Is there an each way to report how much disk space this is costing me?
> > All I can think of is using du or ls across the thing and then back
> > calculating. Also, I don't think I have df access.
>
> Can you use stat?
>
> "stat -c '%b %B' filename" gives the number of blocks and the size in
> bytes of each block:
>
> $ stat -c '%b %B' /etc/passwd
> 8 512
>
> Combine with rough and ready use of find, xarg and bc, and the following
> *might* just give you the size in bytes of the recursive contents of a
> directory:
>
> ( find /some/path -print0 | xargs -0 stat --printf '( %b * %B ) + '
> ; echo 0 ) | bc
Thanks both, it would seem that is giving some sensical answers, but
it would seem that find is assuming a block size of 512 as that's
what's being returned and I'm not convinced this is true...
I should possibly add that this is StaaS storage that is accessed via
SMB/NFS, I suspect some of this filesystem level detail might not be
passed across NFS/SMB.
a
More information about the linux
mailing list