Created
August 25, 2021 10:17
-
-
Save igorvolnyi/34eac6b96fc26c61917599edc8bb0926 to your computer and use it in GitHub Desktop.
Remove all empty directories in current directory (bash, zsh)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Say you have a directory containing thousands of subdirectories. And you want to remove all empty ones. | |
# NOTE: It is not recursive. | |
for d in *; do [[ -d "${d}" ]] && [[ `ls "${d}" | wc -l` = "0" ]] && rmdir -v "${d}"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment