[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: find acting weird

From: Dmitry V. Levin
Subject: Re: find acting weird
Date: Wed, 26 May 2010 19:46:59 +0400


On Wed, May 26, 2010 at 01:42:53PM +0400, Юрий Пухальский wrote:
> I'm trying to remove the directories with find -exec and i've
> encountered that for some reason the behaviour is strange. I've tested
> with 4.1.20, 4.2.27 and 4.4.2.
> I'm doing the following:
> devfe:~>mkdir -p findtest/a/b
> devfe:~>cd findtest/
> devfe:~/findtest>find . -name a -exec rm -rf {} \;
> find: ./a: No such file or directory
> devfe:~/findtest>ls

find(1) is not aware of potential side effects of -exec command.
You can instruct it not to enter processed directories by adding -prune,
e. g. find . -name a -exec rm -rf {} \; -prune

BTW, the find manual recommends to avoid -exec due to security risks;
-execdir is more secure, and -delete is the most secure and efficient.


Attachment: pgptYaUGhNrKJ.pgp
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]