Remove empty directories
low risk
Deletes directories only if they are empty — a safer alternative to rm -r when you expect nothing to be inside.
| Flag | Meaning |
|---|---|
-p | Remove parent directories too if they become empty |
--ignore-fail-on-non-empty --ignore-fail-on-non-empty | Do not complain about non-empty directories |
rmdir buildRemove an empty directory · explain & risk-check →rmdir -p a/b/cRemove c, then b and a if empty · explain & risk-check →Prefer rmdir over rm -r when the directory should be empty — it fails loudly if it is not.
Reference text is hand-written and may be incomplete — check man rmdir for your version. Test destructive commands on a non-production system first.