rmdir — remove empty directories
| Use Case | Command | Description |
|---|---|---|
| 🗑️ Remove empty directory | rmdir directory |
Remove a single empty directory |
| 📂 Remove directory and its empty parents | rmdir -p path/to/dir |
Remove empty directory, then remove each empty parent component |
| 🚫 Ignore errors on non-empty directories | rmdir --ignore-fail-on-non-empty directory |
Exit successfully even if a directory is not empty (skip it) |
| 📢 Verbose removal | rmdir -v directory |
Print a diagnostic for each successful removal |
❌ Remove non-empty directory (use rm) |
rm -r directory |
Recursively delete directories and their contents |
rmdir [OPTION]... DIRECTORY...
If any DIRECTORY argument does not refer to an existing empty directory, it is an error.
The program accepts the following options. Also see Common options.
--ignore-fail-on-non-empty
-p, --parents
DIRECTORY, then try to remove each component of DIRECTORY.
So, for example, rmdir -p a/b/c is similar to rmdir a/b/c a/b a.
As such, it fails if any of those directories turns out not to be empty.
Use the --ignore-fail-on-non-empty option to make it so such a failure does not evoke a diagnostic and does not cause rmdir to exit unsuccessfully.
-v, --verbose
DIRECTORY is removed.
See rm invocation for how to remove non-empty directories (recursively).
An exit status of zero indicates success, and a nonzero value indicates failure.
Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-09 12:34 @2600:1f28:365:80b0:60b0:dfa5:fbc9:9f8f
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)