Shell – Getting size of directories and exclude some folders

command linedisk-usageshell

I have an directory structure like this:

  1. application1
  2. application1_edit
  3. application2
  4. application2_edit

Is there any way to get the total size for every folder (including sub-directories) and exclude all folders with _edit in name?

I have tried du -s on the root folder, but it lists all sub-directories.

Best Answer

Something like this should do it.

$ du -s application[12]

Example

$ ls -l
total 16
drwxrwxr-x 2 saml saml 4096 Nov 28 01:51 application1
drwxrwxr-x 2 saml saml 4096 Nov 28 01:51 application1_edit
drwxrwxr-x 2 saml saml 4096 Nov 28 01:51 application2
drwxrwxr-x 2 saml saml 4096 Nov 28 01:51 application2_edit

Disk usage:

$ du -s application[12]
4   application1
4   application2
Related Question