bug-findutils
[Top][All Lists]
Advanced

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

Re: [bug #61774] Docs for find -delete out of sync


From: Bernhard Voelker
Subject: Re: [bug #61774] Docs for find -delete out of sync
Date: Mon, 31 Jan 2022 22:35:40 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0

On 1/31/22 19:34, admin4 wrote:
> # DANGER! THIS DELETES ALL (!!!) FILES IN THE CURRENT DIRECTORY! (NOT ONLY 
> THE -name “*FILES*” SPECIFIED )
> find . -delete -name "*f25020672.avi*" <- why does it do that? it is like it 
> completely ignores anything after -delete X-D (and just deletes everything in 
> the current dir)

It is pretty clear what happens here:

find(1) was asked to
- start a search in the current directory ".",
- and to delete all files and directories (implicitly using -depth),
- and then to apply the filter for -name '*.avi'.
As the whole command line has already an action (-delete), find does not
implicitly add the default action (-print), and therefore nothing happens
after -name.

I don't think anything surprising is going on here, and find exactly does what
is being asked to do: it processes the command line from left to right.

> # this would have been the correct way to do it
> find . -name "*f25020672.avi*" -delete

Sure, because that first filters for the name, and then performs the deletion
on the remaining files matching that criteria.

And this is what I've tried to emphasize by moving the warning in bold right
after the first sentence about -delete:

  *Warning*: Don't forget that find evaluates the command line as an expression,
  so putting -delete first will make find try to delete everything below the
  starting points you specified.

Have a nice day,
Berny



reply via email to

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