Linux How to search for empty directories?

Status
Not open for further replies.

Gaurish

Galvanizer
Hi,
how to search for empty directory which don't contain any files in them?

I have lot of empty directories present in my home dir. I would want to find them and remove them interactively . it should promt me for confirmation before removal.
 
well....u can use ls -ld to display directories(watch for 5th field which indicates file size, if its 0 then the dir is probably empty)

and can use rmdir -i -R <directoryname> to remove them interactively and recursively

U can combine all these commands using '|'

u may need 'cut' command to cut the filename field
 
Status
Not open for further replies.