Re: [SLUG] file size

From: Paul Bransford (
Date: Fri May 29 2009 - 14:26:24 EDT

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.
> For example, a list of items comes from
> dpkg -L abcde
> This can be modified to show just files with
> dpkg -L abcde | while read file ; do [[ -f $file ]] && echo $file ; done
> How do I find their aggregate size?
> See, I'm trying to build a DVR, and I need to uninstall all unnecessary
> programs to make more space. The fastest way to do that is to uninstall
> the big things first. But, I have to know what they are. I can get a
> list of all installed packages with "dpkg-query -l '*' | grep ^ii | tr
> -s ' ' | cut -f 2 -d ' '", no problem.
> dpkg ... done | du -s
> finds the size of ".", du's default directory. No good.
> du -s $(dpkg ... done)
> finds the size of each file individually. Also no good.
> dpkg ... done | xargs du -s
> does the same thing as the above when the list is small. I imagine it
> does about the same thing when it's large too. Either way, no good.

du -hcs file1 file2 file3... file+n

The last line should give you a total. It looks like you already got
that down.

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

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.
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:04 EDT