1

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.

Community
  • 1
  • 1
Piotr Sobczyk
  • 6,443
  • 7
  • 47
  • 70

1 Answers1

1

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.

Community
  • 1
  • 1
panny
  • 2,186
  • 4
  • 23
  • 26