Question: When I try to delete all files from two or more subdirectories in `zsh`, and a directory is already empty, the following directories are ignored, and files remain.

Example:

```
$ mkdir dir1
$ mkdir dir2
$ touch dir2/blah

# avoid the zsh safety prompt; this may not be necessary for this
# example, just for ease of use here
$ setopt rm_star_silent
$ rm -r dir1/* dir2/*
zsh: no matches found: dir1/*
$ ls dir2
blah

```

In bash, the already empty directory does not stop `rm` from proceeding to `dir2`, and `dir2/blah` is removed.

What is this `zsh` feature, and is there a way to let `rm` behave like in `bash`?

Answer: 
Unlike `bash`, `zsh` by default reports an error in case a filename generation pattern has no matches. This behavior can be changed globally or on a per-pattern basis. 

To prevent error messages from non-matching pattern globally, you can set either of the options `NULL_GLOB` or `CSH_NULL_GLOB`:

* ```
setopt nullglob

```

If a pattern has no matches it will be removed from the argument list. No error message will be printed. In your example

```
rm dir1/* dir2/*

```

would be just expanded to 

```
rm dir2/blah

```
* ```
setopt cshnullglob

```

Also removes non-matching patterns and does not print an error message, unless none of the patterns have a match.

To prevent error messages for single patterns, you can use the glob qualifier `N`, which behaves as if the `NULL_GLOB` option was activated for this pattern:

```
rm dir1/*(N) dir2/*(N)

```

This also would be expanded to

```
rm dir2/blah

```
A good explanation can be found here: 

<https://superuser.com/questions/584249/using-wildcards-in-commands-with-zsh>

The gist is: 

```
By default, ZSH will generate the filenames and throw an error before executing the command if it founds no matches.

```

Your empty directory is going to generate no matches and thus an error.
As the answer indicates, you can either:

1. Enclose the argument in quotes (e.g. `rm -r "dir1/*" "dir2/*"`) OR
2. Setting `unsetopt nomatch` in your `.zshrc` file OR
3. Prefacing you can command with the `noglob` environment variable (e.g. `noglob rm -r dir1/* dir2/*`)