Question

I'm trying to use find command from FindUtils package from gnuwin32 with Windows 7 standard cmd.exe shell.

But when I type simplest possible command involving pattern matching, it doesn't work right.

If I type:

find . -name "*.java"

I end up with: paths must precede expression error. Here I found folowing explanation:

The -name test takes only one argument. In your command line, the shell is expanding the s into more than one argument before the find command is run. Therefore you get the error you see. You should either escape any shell metacharacters in the -name argument or enclose that argument in quotes.

But I am enclosing that argument in quotes!

I tried also with single quotes:

find . -name '*.java'

In this case no files are found (there are plenty of .java files in directory, but I checked '*' for sure, with the same effect).

I also tried:

find . -name \*.java

With the same effect as for double quotes. The same for:

find . -name "\*.java"

What am I doing wrong? In example I found, using double quotes with star worked well.

I think it may be related with this question.

Was it helpful?

Solution

Similar questions here and there. Seems to be related to GNUWin32's find.exe behaving different on Windows Vista and Windows 7 but not Windows XP.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top