rm -r fails to delete entire hierarchy when path goes in and out of it

Ralf Friedl Ralf.Friedl at online.de
Wed Sep 17 09:02:29 UTC 2014


Gian Ntzik wrote:
> It seems that using rm -r with a path that goes into the hierarchy
> intended for removal (and back up e.g. using dot-dots) fails to remove
> the entire hierarchy.
>
> For example,
>
> $ mkdir -p /tmp/a/b/c
> $ mkdir -p /tmp/a/e
> $ rm -r /tmp/a/b/../../a
> rm: can't remove 'a/b/../../a/e': No such file or directory
> rm: can't remove 'a/b/../../a': No such file or directory
GNU rm does this:
$ mkdir -p /tmp/a/b/c /tmp/a/e
$ rm -r /tmp/a/b/../../a
rm: cannot remove '/tmp/a/b/../../a': No such file or directory

In general I think it is not a good idea to pass such arguments to rm.



More information about the busybox mailing list