bug-findutils
[Top][All Lists]
Advanced

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

Re: strange behaviour of find -iname


From: Bernhard Voelker
Subject: Re: strange behaviour of find -iname
Date: Tue, 27 Mar 2018 15:44:11 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 03/27/2018 12:28 PM, address@hidden wrote:
>    Hello!
> 
>    I am not sure this is a bug, but I fail to understand why find -iname
>    works differently according to the directory where I want to find
>    something...

>    address@hidden / # find -iname *astrill*
>    find: paths must precede expression: 20180327_astrill_before_update
>    Usage: find [-H] [-L] [-P] [-Olevel] [-D
>    help|tree|search|stat|rates|opt|exec|time] [path...] [expression]

I think you fell into the same trap as discussed e.g. in:
  https://savannah.gnu.org/bugs/?51711
  https://lists.gnu.org/archive/html/bug-findutils/2017-08/msg00000.html

You need to quote the pattern passed to the -iname option.  Otherwise, the
shell may find and expand the names of the matched files before invoking
find(1).

  $ touch 1astrill1 2astrill2

  $ find -iname *astrill*
  find: paths must precede expression: 2astrill2
  Try 'find --help' for more information.

You see with a prepended echo command what the shell executes:

  $ echo find -iname *astrill*
  find -iname 1astrill1 2astrill2

The next release of find will give a better error diagnostic:

  $ find -iname *astrill*
  find: paths must precede expression: `2astrill2'
  find: possible unquoted pattern after predicate `-iname'?

Have a nice day,
Berny




reply via email to

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