Subject: Re: bug#49994: upgrade: have "-s" of 'ls' display alloc'd sizes for specified "--block-size"

From: Paul Eggert <[email-masked]>
Date: Fri, 20 Aug 2021 08:08:13 -0700

On 8/20/21 12:02 AM, L A Walsh wrote:

> When I use "-b" in du (equivalent to '--apparent-size --block-size=1)

Previously in this thread you asked for "allocated space for a file on a 
device", which is why I was talking about that number.

Now you're asking for apparent size, which is a different number. If you 
want apparent size, you can use 'ls -l', or follow Andreas's suggestion 
and use something like 'stat -c "%s %n"'. However, apparent size might 
be quite different from allocated space, as can be seen in the 1st and 
6th columns of the last two lines of the following:

$ echo '' >a
$ truncate -s 1TB b; echo '' >>b
$ ls -ls --block-size=1 a b
4096 -rw-rw-r-- 1 eggert eggert             1 Aug 20 08:07 a
4096 -rw-rw-r-- 1 eggert eggert 1000000000001 Aug 20 08:07 b