How to remove directory with subdirectories and files?

I'm trying to remove several directories which contains sun-dirs and files inside.
I used the command rm -r <dirname>
But, it always ask "examine file in directory <dirname> yes/no?" line by line.
So, i need to write "y" for every line.
How can i skip this step and remove all directories with asking confirmation?
Thank you.

\rm -rf <directory_name>

1 Like

I have a similar problem. I have a directory with *LOTS* of hidden files (beginning with a . )

In this case when I use rm -rf, I get the error:

rm: Unable to remove directory dir0: File exists

The thing is, I do not know where did all those files come from.. I think I did an nfs mount and something went wrong.. and these random files keep getting produced

-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsD355*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsD455*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsD845*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsD945*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsDA45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsDB45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsDC45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsDD45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsDE45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsDF45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsE055*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsE155*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsE255*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsE355*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsE455*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsE845*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsE945*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsEA45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsEB45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsEC45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsED45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsEE45*
-rwxrwxrwx 1 root engr 8192 May 5 20:35 .nfsEF45*

even in dir0, rm .nfs* does not work.

I'm sorry to say that the suggestion from "encrypted" really doesn't work.

are you sure you have the necessary permissions to operate inside the directory?

typically, rm -rf dir0 should work, even if there are hidden files inside dir0, as long as you have permissions to erase files in the current directory.

I have all necessary permission. But i tried with rm -rf <dirname>, i got the following message.

rm: examine files in directory BioDiversity (yes/no)?

How to skip that questions?

As stated previously, use the "\" before rm -rf <directory_name>

Yes. It works when i put "\".
I'm sorry that I did not put "\" before.
Thanks a lot.

Thanks. It worked..)

Hi encrypted,

Could you explain the difference between "rm" and "\rm".
"\rm" command is new to me......

Thanks...