# find: unknown primary or operator



## rob34 (Feb 17, 2012)

[CMD="u"][/CMD]Tonight I executed a command that I've probably run thousands of times: 

```
find . -name *.php
```

And I got a strange, single line response instead of a list of php files:

```
find: cron.php: unknown primary or operator
```

There is a file called cron.php in the working directory.  There is nothing special about that file; it's just another php file.

If I move up one directory (from /usr/local/www/drupal7 to /usr/local/www) and execute the same command it runs fine.

The following command runs perfectly from several other directories that I tried, just not from /usr/local/www/drupal7:

```
find /usr/local/www/drupal7 -name *.php
```

This behavior occurred on a FreeBSD 9.0 AMD64 machine.  I have a 7.4 AMD64 machine that has the same directory structure and I get a similar error there.  Instead of "unknown primary or operator", I get "unknown option."

Has anyone else seen anything like this?  Am I doing something wrong?


----------



## phoenix (Feb 17, 2012)

*** is expanded by the shell before the command-line is passed to find(1).  If there's only 1 item in the directory, then it works.  If there's more than one item in the directory, then it fails as the command-line options are no longer correct.

The correct command-line is:
`# find . -name '*.php'`

You have to escape the *** so that find does the expansion internally.


----------



## rob34 (Feb 17, 2012)

That worked perfectly. Thanks!


----------



## pkubaj (Feb 18, 2012)

phoenix said:
			
		

> *** is expanded by the shell before the command-line is passed to find(1).  If there's only 1 item in the directory, then it works.  If there's more than one item in the directory, then it fails as the command-line options are no longer correct.
> 
> The correct command-line is:
> `# find . -name '*.php'`
> ...



I'd like to note that
`# find . -name \*.php`
also works (for me at least).


----------

