find(1) removes as it should a directory, but after this it complains about
Christian Weisgerber
naddy at mips.inka.de
Wed Apr 22 15:00:18 UTC 2020
On 2020-04-20, Matthias Apitz <guru at unixarea.de> wrote:
> I've stumbled over something with find(1) which I would call a bug:
>
> $ mkdir foo
> $ find foo -type d -execdir rm -rv {} \;
> foo
> find: foo: No such file or directory
find(1)...
* sees the directory entry "foo";
* evalutes the expression for it, which as a side effect executes
an action;
* tries to recurse into "foo", since it is a directory.
That's perfectly reasonable. find(1) can't know that the action
removed the directory. If your exec removes a directory, you should
tell find(1) to not recurse into it:
$ find foo -type d -prune -execdir rm -rv {} \;
--
Christian "naddy" Weisgerber naddy at mips.inka.de
More information about the freebsd-questions
mailing list