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.9.26-5-g7740029 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-25 07:29 @216.73.217.127
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)