Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print in bytes with "du"

Tags:

bash

filesize

du

I am using du -sh to see the size of directories. If I check a 1KB directory, I will see:

1.0K    .

However, I want the output in bytes, and only the bytecount.

For example:

$ du -sh .
1024
like image 823
leetbacoon Avatar asked Dec 22 '19 07:12

leetbacoon


1 Answers

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
like image 162
Romeo Ninov Avatar answered Sep 27 '22 16:09

Romeo Ninov