What is the command to delete an empty folder (no files or subdirectories)?

2

I am using Fedora10 linux. I want to delete a folder if that folder doesnot have any file or subdirectories inside it. I know the path of the folder.

What is the command to delete a folder is the folder doesnot have any files or sub directories.

Thanks
Sunil Kumar Sahoo

Deepak

Posted 2009-11-18T13:04:36.293

Reputation: 151

Also a duplicate of http://stackoverflow.com/questions/1755689/

– None – 2009-11-18T13:08:32.377

Hi Pascal, The question is not duplicate. In this question I want if my directory is empty then only delete otherwise donot delete the directory. – None – 2009-11-18T13:13:07.680

Answers

7

Use rmdir:

rmdir [path to folder]

rjmunro

Posted 2009-11-18T13:04:36.293

Reputation: 1 078

rmdir will remove the directory irrespective of knowing whether the directory is empty or not – None – 2009-11-18T13:15:33.870

Sorry rjmunro, U are right. I right. I got success after using rmdir. Thanks alot. – None – 2009-11-18T13:44:06.260