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: 
The best way is to make it a single glob that matches files in both directories.

```
rm (dir1|dir2)/*

```

That way, the command is still not run if no file is found.

Note however that `dir1`/`dir2` can't contain `/`.

In those cases, you could do instead:

```
files=(foo/bar/*(N) bar/baz/*(N))
if ((#files)); then
  rm $files
else
  echo >&2 No matching file
fi

```

Or use `cshnullglob` to get the csh or pre-Bourne sh behaviour. That's still better than reverting to the bogus (IMO) behaviour of `bash` (where non-matching globs are passed asis to the command) which you can do with:

```
set +o nomatch

```
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/*`)