I am using du -sh to see the size of directories. If I check a 1KiB directory, I will see:
1.0K . However, I want the output in bytes, and only the bytecount.
For example:
$ du -sh . 1024 To get size in bytes you should use command on this way:
du -sb (this b mean bytes)
for the du which do not work properly with -b you can use
du -s --block-size=1 --block-size=1 mean in bytes. As --block-size=1k==-k-B1 is equivalent to --block-size=1, but rounds up to at least 512. There is -A for apparent size, which turns off the rouding according to man page, but issuing du -A -B1 dir produces 512 blocks anyways. I have to use du -h -A -B1 to get file sizes in giga/mega/kilobytes, which shows correct value. I don't know if it is a bug in macOS du or in other BSD unices. (Alternatively, install gnu coreutils on macOS via macports).
hflag then? Read the man page.hI do not get a byte count. For example, an 8K directory gives me16without-h. 8 kilobytes is not 16 bytes.dustands for disk usage, i.e. how much space does this file/directory use on disk (sectors, etc). It does not stand for how many bytes are stored in the file, but more how many bytes are needed to store a file of N Bytes of content. The pure byte count is done withdu -b. See I'm confused by the output ofdudu, but that is okay. I also piped throughgrep -o '^[0-9]\+'to get the true output I needed