LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   deleting directory w/o descending (https://www.linuxquestions.org/questions/linux-newbie-8/deleting-directory-w-o-descending-356372/)

STAGED 08-24-2005 12:01 AM

deleting directory w/o descending
 
how do i delete a directory without descending and having to delete every content inside. i tried doing 'prompt' and 'rm -r' but to no avail.

thanks:study:

newinlinux 08-24-2005 12:22 AM

you can add a f to rm -r becoming rm -rf

aeruzcar 08-24-2005 12:33 AM

It is weird that rm -r does not just work, as newinlinux said try with rm -rf

dalek 08-24-2005 01:35 AM

Make SURE you type that in right, especially if you are root. It does not ask questions about what you are doing.

I had moved my Gentoo to a new hard drive and I booted the old drive and typed in rm -rf /* just to see what it would do. It ran until it deleted something that it needed then errored out. About 90% of the files were gone, I think it was something in /usr/sbin. Trust me, it will delete what you tell it, even if you tell it wrong. :tisk:

Later

:D :D :D :D

doc.nice 08-24-2005 07:46 AM

<info>
some distros do an alias rm="rm -i" as default, for new users coming from windows...

normally these are in /etc/tcshrc.alias or /etc/profile or /etc/bashrc or whatever shell is in use...
</info>

MensaWater 08-24-2005 08:39 AM

rm -r alone doesn't work because by default rm doesn't remove directories - only their contents and tells you it can't remove a directory because it is a directory. The -f flag says to disregard all warning conditions and force the remove.

As pointed out by others it is useful for removing an entire directory tree but can be very dangerous if you don't use it correctly.


All times are GMT -5. The time now is 06:32 PM.