Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I hope this isn't too trivial, but for some reason I can't get a simple command to execute.

I'm writing a file manipulation script and I have several directories called test, test2, etc each containing several files.
I type:
rmdir --ignore-fail-on-non-empty test*

I get a prompt with no error messages as if the command executed cleanly. I ls the directory I'm in and get:
test test2 test3 test4

I know I'm missing something obvious; anyone have a clue what it is? Yes, I'm in the parent directory. Yes, the option is typed correctly -- I checked the manpage twice.

share|improve this question
Solved by doing rm -r test* but I still want to know what's wrong. :-) – Yitzchak Aug 10 '11 at 17:22
Does running it with --verbose shed any light on the situation? – EBGreen Aug 10 '11 at 17:22
if you want to ignore failing on empty, why not rm -rf test*? (edit: nevermind, you just commented about having fixed it) – EricR Aug 10 '11 at 17:22
@EricR Why f? Doesn't the f option go up? I don't think I'd want that. – Yitzchak Aug 10 '11 at 17:24
@Yitzchak "-f ignore nonexistent files, never prompt". afaik there's no option to ascend with rm. – EricR Aug 10 '11 at 17:26
up vote 6 down vote accepted

rmdir --ignore-fail-on-non-empty does exactly what it says on the tin, it ignores failures when not empty; i.e., it does nothing.

An alternate solutions to your problem would be rm -r or rm -rf , using -f in order to "ignore nonexistent files, never prompt".

share|improve this answer
This is the best answer, it explains the ambiguity of the man page. @EricR, I would add other ways to do what the OP wants to do (rm -rf) – n0pe Aug 10 '11 at 17:38
@MaxMackie, fixed. I had left them in the comments. – EricR Aug 10 '11 at 17:58

rmdir removes empty directories. It does not remove non-empty directories. There is no way to make it remove non-empty directories.

share|improve this answer

rmdir does not remove non-empty folders at all.

Use rm -rf ./test* for this. But be very careful about the path you give rm

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .