Frage

I think that the format of this command changed since I've last used it, and now I'm not understanding what it expects of me.

I'm getting an error: find: unknown predicate '-name=*.xml'

The way it seem to be trying to invoke find is like this:

find . \( -name="*.xml" \) -ls

I don't understand this syntax :( Is it trying to create a nested shell? Why if so? Is it trying to create a list of arguments? Why if so?

I might just go and edit this function to remove the parenthesis, but why would anyone put them there? I must be missing something.

War es hilfreich?

Lösung

The parenthesis group the search terms you put together into a logical grouping so they wouldn't affect anything else afterward. I suspect they're put there to fully encapsulate anything you might put in there so that the -ls (or any other option it may add due to other variable settings, etc) always executes. Parenthesis are the highest order of parenthesis. It is not trying to create a nested shell; that's why the \s are there: it's passing them to find itself.

But your real issue is that find needs the -name with a space after it, not with an = sign. (ie, the argument to -name should be a separate argument). It doesn't work like many of the double-dash arguments that you expect from other tools (in particular, the ones written using the GNU getopt_long parsing implementation.

So, try -name *.xml instead.

And for an additional piece of information, here's the find man page about ()s:

   ( expr )
          Force  precedence.   Since parentheses are special to the shell,
          you will normally need to quote them.  Many of the  examples  in
          this  manual  page  use  backslashes for this purpose: `\(...\)'
          instead of `(...)'.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top