You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
338 B
Plaintext

2 years ago
#!/bin/sh
# recursively delete empty directories
rmdir_empty() {
# make default . explicit
if [ -z "$1" ]; then
set -- .
fi
# do the first level directories first
for maxdepth_opt in "-maxdepth 1" ""; do
find "$@" -depth -mindepth 1 $maxdepth_opt \
-type d -empty -exec rmdir -v {} \;
done
}
rmdir_empty "$@"