Delete empty directories below the current directory
Build a paste-ready command, then review its compatibility and effects before running it.
find . -type d -empty -deleteDestructive command. Review the target and use a preview or dry-run variant first. Safer first stepfind . -type d -empty -printRun this lower-risk preview or inspection variant before the state-changing command. Compatibility
Linux + macOSVerified for Linux, macOS using posix, bash, zsh syntax.
Operational knowledgereview due 2027-01-19
Requirementsfindfind must be installed and available on PATH.
Version supportfind Current supported releasesVerified for linux, macos using posix, bash, zsh syntax; consult compatibility notes for platform-specific differences.
Expected signals(no terminal output on success)Representative successful output; values vary with the selected target and system state.
Known errorsfind: command not foundfind is missing or is not available on PATH.
Verifyfind . -type d -empty -printThe preview shows only the intended targets before applying the change.Rollback noteNo universal automatic rollback is available. Capture the current state and use the tool-specific recovery procedure before applying changes.
Command breakdown
01findCommandRuns the find stage of this one-liner.
02.ArgumentPasses . to find.
03-typeOptionConfigures find with the -type option.
04dArgumentPasses d to find.
05-emptyOptionConfigures find with the -empty option.
06-deleteOptionConfigures find with the -delete option.
Example input
find . -type d -empty -delete
Example output
(no terminal output on success)
Empty directories below the current directory are removed.
Illustrative output — exact values vary by system and data.
Official sources