Re: [SLUG] file size

From: Eben King (
Date: Fri May 29 2009 - 16:01:44 EDT

On Fri, 29 May 2009, Paul Bransford wrote:

> Eben King wrote:
>> If I have a bunch of assorted files, how can I find out their total
>> size? Quickly is a definite plus, since this will happen hundreds of times.
> du -hcs file1 file2 file3... file+n
> The last line should give you a total.

| -c, --total
| produce a grand total

Excellent, why didn't I see that? Now I wonder if there's a way to get du
to skip the intermediate totals so I can drop the "tail". And apparently
some files have the ever-cursed space in their names, so I haven't figured
out how to make the script deal with them.

(I don't want it human-readable since it's hard to sort, so I'll drop the

> So, the question is how do you get a list of files?

Done that part:

dpkg-query -l '*' | grep ^ii | tr -s ' ' | cut -f 2 -d ' '

Anyone know a faster or cleaner way?

> Maybe storing the dpkg output to a file, and catting that back in with
> something like this:
> dpkg -L {abcde,foobar,other-packages} >> /tmp/files
> du -hcs (cat /tmp/files)
> I'm not sure how that would handle the newlines in /tmp/files. you may
> need to add a sed command to process /tmp/files into a big long list.

dpkg -L $PACKAGES | tr '\n' '\0' >> /tmp/files
du --files0-from /tmp/files

Or something like that.

-eben      QebWenE01R@vTerYizUonI.nOetP
Scientist A: A matterbaby is a very unstable particle.
Scientist B: What's a matterbaby?
Scientist A: I'm doing fine honey, how you doing? -- mrshowrules on Fark
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS).  Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.

This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:00:31 EDT