Total size of multiple directories
bbelnap at gmail.com
Fri Jun 25 14:29:33 MDT 2010
On Fri, Jun 25, 2010 at 1:53 PM, Bob Belnap <bbelnap at gmail.com> wrote:
> How about using the -c option to du?
> find . -iname "*pic*" -type d | xargs du -shc
> -c should give you a total of all dirs listed.
I should include a few caveats in here though (some I just learned :)
The above will work,
but you'll want to watch out for argument limits to xargs that will
break up your list of files.
You can get around this with something like:
find /usr/ -type d -print0 | du -chs --files0-from=-
which will suck in and give the total of all find's output.
However, you may get bitten by find outputting more than you want. In
the above example,
du will sum both /usr and /usr/local, /usr/share, etc. Meaning, it
will include all the files in /usr,
all the files in /usr/local (which have already been included in
/usr), all the files in /usr/local/sbin
(which have already been included in both /usr and /usr/local) etc.
You can end up with
inflated totals unless you have a very specific find.
But for your case, probably du -chs is enough:
du -chs dir1 dir2 /some/other/path another_file.txt
More information about the PLUG