On 03/27/2018 12:28 PM, r...@gommes.eu 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...

>    root@ZB17 / # 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