bashfilesizedu

Print in bytes with "du"


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

Solution

  • 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