Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to delete a massive directory and cannot get the rm command to work.

I want to delete the widget directory which contains thousands of files and folders. Obviously I do not want to descend into each subdirectory and have to confirm the deletion for all 5,000 files/folders.

So I type:

rm -r widget

The prompt asks me:

rm: descend into directory 'widget'?

I type no and then re-run an ls. The folder is still there. If I rerun the rm -r widget command, but instead this time type yes, it will descend into the massive subdirectory structure as predicted.

What is going on here?

share|improve this question
1  
Type alias in the shell. Is there one for rm that looks like alias rm='rm -i'? –  ott-- Dec 5 '11 at 15:55
    
rm -r widget should normally ask if -f isn't given, shouldn't it? Or did I add that alias and completely forget about it? –  Rob Dec 5 '11 at 16:17
1  
@Rob it must be that the -i is set. rm -rdeletes recursive and asks for readonly files, rm -ri shows the above behaviour and rm -rf just removes. –  ott-- Dec 5 '11 at 17:43
    
I set it up so long ago I didn't even remember, that'll save me one day, thanks! –  Rob Dec 5 '11 at 18:06

1 Answer 1

up vote 2 down vote accepted

When you are typing no you are telling it not to recurse down into the widgets directory.

This is why when you typed in yes later on that it did go and delete them.

If you use rm -rf Widgets it will not prompt you for confirmation, but you don't get a second chance if you typo

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.