24

I know about du -sh which gives me total disk space used for given directory.

My problem is the directories I am interested are scattered in lot of subdirectories. I have right "find" command that gives me these directories. Goal is to pass directories found and get total disk space used by these directories

If I pass these directories as arguments to du I get total used for that directory, but no grand total. I want to get the grand total.

Exampledu -sh dir1 dir2 gives output something like follows

17k dir1 55K dir2

What do I need to do to get the grand total?

  • 3
    Try du -sh --total . And man du ;-) – Rmano May 13 '14 at 18:16
  • 1
    Thank you. It works. I actually did man and tried --files-from and some other options. Somehow totally missed the --total, mostly because of my inability to read 2nd equivalent parameter for "-c" :) – user871199 May 13 '14 at 18:23
24

Use the flag --total in the du command.

du -sh --total dir1 dir2

From man du:

   -c, --total
          produce a grand total
| improve this answer | |
  • 1
    Small addition: options can be combined and tail can be used to trim the output, as du -cs /etc /tmp | tail -n 1 – Sergiy Kolodyazhnyy Feb 3 '17 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.