To delete an empty directory, use the -d ( –dir ) option and to delete a non-empty directory, and all of its contents use the -r ( –recursive or -R ) option. The -i option tells rm to prompt you to confirm the deletion of each subdirectory and file.
How do I delete empty directory in Unix?
To remove a directory that is not empty, use the rm command with the -r option for recursive deletion. Be very careful with this command, because using the rm -r command will delete not only everything in the named directory, but also everything in its subdirectories.
Which command will delete an empty directory?
To remove directories which are in fact empty is then easy. In any file system containing multiple directories, you can issue the “rmdir *” command knowing that only the empty directories will be removed.