emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#22363: closed (Bug of stat in bash)


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#22363: closed (Bug of stat in bash)
Date: Wed, 13 Jan 2016 17:25:02 +0000

Your message dated Wed, 13 Jan 2016 10:24:20 -0700
with message-id <address@hidden>
and subject line Re: bug#22363: Bug of stat in bash
has caused the debbugs.gnu.org bug report #22363,
regarding Bug of stat in bash
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
22363: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22363
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: Bug of stat in bash Date: Wed, 13 Jan 2016 15:14:04 +0000 (UTC)
Hi.
I've needed isolate the size of a directory writing a script. I've used "stat -c %s directory", but the result is a great surprise. You can view the image stat.jpg: the size of /var/cache/apt/archives is 9804 KB (10 MB aprox.), but stat shows "159744". This number is the same if the directory have 60 MB, 10 MB or 0 MB. In other equal instalation (Ubuntu 14.04) this number showed 4096 with more than 300 MB in the same directory.
In the stat2.jpg image you can view the same situation with the directory empty.
It's a bug? The way to obtain my goal (only the number) is another? I've read the manual of stat and I can't discover another way. Reading pages in Internet, this is the way explained to achieve my goal...
My system: Ubuntu 14.04; Terminal: Gnome 3.6.2.
Thanks for your attention.
 
                                          Arturo

Attachment: stat.jpg
Description: JPEG image

Attachment: stat2.jpg
Description: JPEG image


--- End Message ---
--- Begin Message --- Subject: Re: bug#22363: Bug of stat in bash Date: Wed, 13 Jan 2016 10:24:20 -0700 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0
tag 22363 notabug
thanks

On 01/13/2016 08:14 AM, Arturo wrote:
> Hi.
> I've needed isolate the size of a directory writing a script. I've used "stat 
> -c %s directory", but the result is a great surprise. You can view the image 
> stat.jpg: the size of /var/cache/apt/archives is 9804 KB (10 MB aprox.), but 
> stat shows "159744". This number is the same if the directory have 60 MB, 10 
> MB or 0 MB. In other equal instalation (Ubuntu 14.04) this number showed 4096 
> with more than 300 MB in the same directory.
> In the stat2.jpg image you can view the same situation with the directory 
> empty.

In the future, please don't spam the list with a .jpg screenshot of a
terminal, when a simpler text-based copy-and-paste of its contents will
convey the same information with a lot less bandwidth.  Remember, ever
100kb you send in a .jpg turns into megabytes of outgoing traffic when
it is multiplied to all list subscribers.

> It's a bug?

No. The size of a directory is heavily dependent on the file system in
use, but in general is a multiple of the file system sector size (for
example, if the minimum size you can allocate in a file system is 64k,
but the information required to describe a single entry in a directory
occupies only 512 bytes, then a directory in that file system would show
up as 64k in size if it has anywhere between 1 and 128 entries, and
would jump to 128k in size if it has between 129 and 256 entries).

The 'stat' program is merely reporting to you the information reported
by the operating system, which in turn is reporting what the file system
is using.  It is NOT coreutils' fault that the number reported is not
the number you are looking for.  In other words, when you are asking
stat for the size of the directory, you are getting how much space the
directory itself occupies on the disk, and NOT recursing into how much
space its contents occupy.

> The way to obtain my goal (only the number) is another?

It sounds like what you are asking for is the cumulative size of all
files within a directory, added together, and NOT how much space the
directory itself occupies on disk.  The program for that is 'du'
(mnemonic for 'disk usage'), not 'stat'.

Maybe we are missing a link on the 'stat' manual page pointing to 'du',
but other than that, I see no problem here, so I'm closing the report.
However, feel free to reply with any further related questions.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]