• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Removing a directory in Linux

 
Joe Harry
Ranch Hand
Posts: 10047
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I have a doubt with the rmdir command. What is the exact difference between rmdir -p and rmdir -R? The documentations says, -R option deletes the files in the directory and the former just deletes the directory. But my question is when a directory is deleted, where will the files be? They would also be deleted/ Or is it that rmdir -p throws an error if there are any files in the directory that we specified?
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

when a directory is deleted, where will the files be


That depends on which command that you use. If you use rmdir -p, you need to ensure the directory is empty (the directory can contain another empty directory and so on) or else you'll get an error. If you use rm -r, it'll delete everything regardless whether the directory is empty or not.

BTW, I don't see any see any option for rmdir -R in my bash, did you mean rm -r?
 
Costi Ciudatu
Ranch Hand
Posts: 74
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use rmdir -p, you need to ensure the directory is empty (the directory can contain another empty directory and so on) or else you'll get an error.

-p deletes empty parent directories, not empty children; rmdir will fail on any non-empty directory (even if that only contains an other empty directory).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic