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?
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?
SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Costi Ciudatu
Ranch Hand
Joined: Oct 24, 2006
Posts: 74
posted
0
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).