Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link
./a |-/bx1 |-/by2 |-/bz3 |-/bx4 |-/by5 

Now I want to apply du to all sub-folders except for /by2 and /bx4.

I can make it happen for one folder:

du --max-depth=1 --exclude=./by2 

but not for two.


I found to related questions:

  1. Getting size of directories and exclude some foldersGetting size of directories and exclude some folders
  2. Using --exclude with the du commandUsing --exclude with the du command

In (1) regular expressions are applied which won't work in my case - at least not comfortably. In (2) the exclusion refers to a full sub-directory. Essentially my question is:

Can I feed --exclude a list of files/directories and if yes, how?

./a |-/bx1 |-/by2 |-/bz3 |-/bx4 |-/by5 

Now I want to apply du to all sub-folders except for /by2 and /bx4.

I can make it happen for one folder:

du --max-depth=1 --exclude=./by2 

but not for two.


I found to related questions:

  1. Getting size of directories and exclude some folders
  2. Using --exclude with the du command

In (1) regular expressions are applied which won't work in my case - at least not comfortably. In (2) the exclusion refers to a full sub-directory. Essentially my question is:

Can I feed --exclude a list of files/directories and if yes, how?

./a |-/bx1 |-/by2 |-/bz3 |-/bx4 |-/by5 

Now I want to apply du to all sub-folders except for /by2 and /bx4.

I can make it happen for one folder:

du --max-depth=1 --exclude=./by2 

but not for two.


I found to related questions:

  1. Getting size of directories and exclude some folders
  2. Using --exclude with the du command

In (1) regular expressions are applied which won't work in my case - at least not comfortably. In (2) the exclusion refers to a full sub-directory. Essentially my question is:

Can I feed --exclude a list of files/directories and if yes, how?

Source Link
Raffael
  • 961
  • 4
  • 9
  • 17

How to apply du (f.x.) to all sub directories except for some of them?

./a |-/bx1 |-/by2 |-/bz3 |-/bx4 |-/by5 

Now I want to apply du to all sub-folders except for /by2 and /bx4.

I can make it happen for one folder:

du --max-depth=1 --exclude=./by2 

but not for two.


I found to related questions:

  1. Getting size of directories and exclude some folders
  2. Using --exclude with the du command

In (1) regular expressions are applied which won't work in my case - at least not comfortably. In (2) the exclusion refers to a full sub-directory. Essentially my question is:

Can I feed --exclude a list of files/directories and if yes, how?