-
rmdir
How can I remove a non-empty directory in UNIX? Let's say i had a directory called "myFolder", I know that "rmdir myFolder" should do the trick but I get complaints that the directory still has contents in it. I know there has gotta be a way to do this (unless i have to manually erase 100 files from directory "myFolder" in order to remove "myFolder").
Thanks in advance.
-
use rmdir with the -R switch, this will erase the directory and its contents. Note: if you are logged in as root (superuser) be careful with this command.
-
rm -R will recursively delete the contents of the directories and the directories themselves.
And you woudn't have to "manually" delete the files in a directory. rm * will delete all the files in the current directory.
-
thanks guys for your help!
-
Actually, some problems again...
say i have a directory called "test", and in this directory are 2 files called "test1" and "test2".
Ok so i cd to "test" and try the <rm *> command.
i get back something like this:
$ rm *
rm: remove test1 (yes/no)? y
rm: remove test2 (yes/no)? y
$
it prompts me to remove each file!? so if there are a 100 i have to type 'y' 100 times??
Than i tried the <rm -R>:
i get something similar again:
$ rm -R test
rm: examine files in directory test (yes/no)? y
rm: remove test/test1 (yes/no)? y
rm: remove test/test2 (yes/no)? y
rm: remove test: (yes/no)? y
$
again it prompts each file! Also a a note, I tried replying "no" to "examine files in directory test (yes/no)?", thinking that by answering "no" i would'nt be prompted about each file. But nothing gets deleted? By the way, this is not linux but SunOS-5.8 (still unix); i don't know if that has anything to do with it?
i'm new to this stuff and appreciate the help!
-
It's because you have some alias to rm as rm -i in your
.bashrc or one of dotfiles. I genearly don't like
this, some distros put the entry some don't I guess.
rm -f should do it
-
Try unalias rm, if you're using Bash(I assume so)
Typing 'a' at the prompt instead of y or n might do the trick, too.
Also, you should remove the line from the ~/.bashrc file, too.