(Probably) trivial question about rmdir

3

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.

Yitzchak

Posted 2011-08-10T17:19:31.137

Reputation: 4 084

Solved by doing rm -r test* but I still want to know what's wrong. :-) – Yitzchak – 2011-08-10T17:22:48.523

Does running it with --verbose shed any light on the situation? – EBGreen – 2011-08-10T17:22:53.063

if you want to ignore failing on empty, why not rm -rf test*? (edit: nevermind, you just commented about having fixed it) – EricR – 2011-08-10T17:22:57.150

@EricR Why f? Doesn't the f option go up? I don't think I'd want that. – Yitzchak – 2011-08-10T17:24:55.353

@Yitzchak "-f ignore nonexistent files, never prompt". afaik there's no option to ascend with rm. – EricR – 2011-08-10T17:26:08.737

@EricR, right you are. I guess I'll remember the rest of the manpage now. – Yitzchak – 2011-08-10T18:34:59.093

Answers

8

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".

EricR

Posted 2011-08-10T17:19:31.137

Reputation: 453

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 – 2011-08-10T17:38:40.777

@MaxMackie, fixed. I had left them in the comments. – EricR – 2011-08-10T17:58:47.620

0

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

William Jackson

Posted 2011-08-10T17:19:31.137

Reputation: 7 646

0

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

sinni800

Posted 2011-08-10T17:19:31.137

Reputation: 3 048