Need help sending results of find into rmdir

Basically, I’m attempting to do the following but it errors out so it must not be possible this way. However, there must be some alternate way of accomplishing it. I just need a little assistance.

This is what I tried to do:

find /var/log/audit -mtime 5 | rmdir --ignore-fail-on-non-empty

I’m trying to get rmdir to use the output of the find command as input for removing directories that are not empty and are more than 5*24 (in other words, 5 days) old.

Hi
Use exec and rm ;

find /var/log/audit -mtime 5 -exec rm -r {} \\;


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 12.1 (x86_64) Kernel 3.1.10-1.9-desktop
up 1 day 12:49, 3 users, load average: 0.00, 0.01, 0.05
CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU

[QUOTE=dwoeltje;4299]Basically, I’m attempting to do the following but it errors out so it must not be possible this way. However, there must be some alternate way of accomplishing it. I just need a little assistance.

This is what I tried to do:

find /var/log/audit -mtime 5 | rmdir --ignore-fail-on-non-empty

I’m trying to get rmdir to use the output of the find command as input for removing directories that are not empty and are more than 5*24 (in other words, 5 days) old.[/QUOTE]

In addition to Malcom’s answer - the original command did not work for multiple reasons:

The used syntax makes the output of the first command the “standard input” of the second command, not its parameters… you might have accomplished that via “rmdir --ignore-fail-on-non-empty $(find /var/log/audit -mtime 5)” in a bash script (other shells may use a different syntax).

But still, “rmdir” will only remove empty directories. “–ignore-fail-on-non-empty” will simply not report non-empty directories as errors, so that you can invoke it with i.e. wildcards and still check it’s rc for “more severe causes of failure”. So, non-empty directories are preserved.

Regards,
Jens