Remove a non-empty directory in Terminal

I love using the command line like a ninja, but its also really annoying when you don’t know the exact right command or option.  I was trying to delete a directory the other day, and kept getting the annoying error “Directory not empty”

Screen Shot 2013-08-03 at 11.37.20 AM

So here is how to fix it.  I found the answer here, as I will outline below.

Use the ‘-R’ option with the ‘rm’ command to delete an empty directory.  If the directory has relatively few files, I recommend using the ‘-i’ flag, as that will ask you to confirm each file to delete.   See the screenshots below for an example:

Screen Shot 2013-08-03 at 11.41.14 AMHope you found this useful!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s