Which file size is most accurate between ll, ls, and block size M or G?

555 views Asked by At

So take the following dir:

      4096 dir1
7255937636 dir2

This is what I get with just an ll command. If I do ls -l --block-size=M I end up with:

   1M dir1
6920M dir2

Finally if I do ls -l --block-size=G I end up with:

1G dir1
7G dir2

I get that 6920 is easily rounded up to 7G but it seems like it's a big stretch to round that 4096 up to 1G. I also don't understand why the second example isn't 7256M or something more similar. Even more if we're always rounding up, why isn't the 7256 rounded up to 8G?

I guess I don't fully understand what it is I'm looking at here when nothing gives as accurate value as I'm thinking.

1

There are 1 answers

0
Rob On

Apparently you are confusing the blocksize with the unit used for displaying the (correct) size. Try using

ls -lh

to enable auto scaling for human-readable output.

BTW: ll usually is just an alias for ls -l. This is also the most accurate value you will get.