Solved How do I get directory size in bytes?

I am using du -s to get the total amount of disk space that a folder occupies, all files and sub-folders included.

I have this folder named aa (for the sake of brevity) with a filed named bb.mkv in it, which is a bit larger than 11GBs. However, when I run the command du -s /tank/somevolume/aa, I get this:

Code:
11927273        /tank/somevolume/aa

I have done research but nothing useful has come up. How do I do this?
 
du won't show you bytes because files use space in blocks
you can script something to sum the file sizes in bytes but that wont be accurate in terms of disk usage
think hard links, sparse files, filesystem compression etc

find /some/dir/somewhere -type f |xargs stat -f %z|awk '{s+=$1} END {print s}'
 
The -h option is useful. But it's going to translate to kB, MB and GB for example. There's no option to show the bytes.
 
du won't show you bytes because files use space in blocks
you can script something to sum the file sizes in bytes but that wont be accurate in terms of disk usage
think hard links, sparse files, filesystem compression etc

find /some/dir/somewhere -type f |xargs stat -f %z|awk '{s+=$1} END {print s}'

It worked. Thanks.
 
Back
Top