This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

This does not answer your question, but could solve the underlying problem. I often use the construct: WORK=$(mktemp -d) or cd $(mktemp -d). Of course don't put important files that you need to preserve in those directories. But most likely your system is already setup to automagically make those files disappear after a while.
–
emoryAug 25 '12 at 23:35

I have my machine mount a tmpfs ram drive to the /z/ directory on start-up and do all my temporary work there.
–
RichardOct 21 '13 at 20:23

2 Answers
2

The find command is the primary tool for recursive, filesystem operations.
Use the -type d expression to tell find you're interested in finding directories only (and not plain files). The GNU version of find supports the -empty test, so

$ find . -type d -empty -print

will print all empty directories below your current directory.
Use find ~ -… or find "$HOME" -… to base the search on your home directory (if it isn't your current directory). After you've verified that this is selecting the correct directories, use -delete to delete all matches:

Good solution, but it should be noted that not all version of find have -empty.
–
jordanmAug 25 '12 at 21:49

@Baldrick Doesn't looks from home directory if I run it form ~/Desktop.
–
Santosh KumarAug 25 '12 at 21:58

@Santosh: The command as it is, is meant to be run from your home directory (that's why I added ~$ in the beginning). If you want to run it regardless of your working directory, use "$HOME" instead of . as jordanm suggested in his answer.
–
BaldrickAug 25 '12 at 22:09