How to remove a directory with files in it.
Trying to delete a directory with files in and I don't want to be prompted for a yes answer.
|
"rm -rf directory" should do it.
|
Code:
rm -rf /path/to/directory |
A tip to keep in mind when deleting files would be the structure of directories and how they are referenced. For instance, if you are in "/foo" and inside that directory, there is another named "bar" you would run:
rm -Rf ./bar From foo. The ./ just makes sure you are deleting from your working directory. If at any point, you need to know where you are, run `pwd` to print your working directory. There are countless times that I ahve seen people mistakenly delete /etc because there was an etc dir inside their current working directory and they typed 'rm -Rf /etc' instead of 'rm -Rf ./etc' or 'rm -Rf etc'. In short: Be careful. Its hard to un-do that type of mistake. Especially on ext3 :). Michael Piekarski Network Engineer mpiekarski@hostmysite.com www.hostmysite.com |
Damn...I just use the trash can...what's the difference?
Is there a difference between that and the trash can and delete? |
Yeah, if you dump it in the trash can, it can easily be recovered as long as you don't clean the trash. An rm -rf deletes things permanently.
For safety, you may want to use rm -rfi. Unlike plain -rf, it will prompt for confirmation. Always place the i option last! |
The trash can is just another folder. When you send something to the can you are moving it, not deleting it.
|
One safe way is :
Code:
cd <dir to delete> |
Thanks
Thank you all so much! Great info.
|
All times are GMT -5. The time now is 12:31 AM. |