Tuesday, February 19, 2013

Removing Empty Directories

We can remove empty directories inside a directory by using following command

$ ls -l * | grep -B1 "^total 0K" | grep -v -e "total 0K" -e "--" | cut -d: -f1 | xargs rmdir -v

The above command cannot delete recursively. Hence, using find command to delete recursively.
$ find . -type d -empty -delete

No comments: