Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to find all my GRAPHML files under the current directory in bash. So I ran the following command:

find . -name *.graphml

And I get the error message:

find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]

What is wrong with the command above? The strange thing is that it works fine for other regexps.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Always enclose the pattern in quotes (e.g. *.graphml in your case). Otherwise it will be expanded by the shell before the find command. This means that find does not get a literal *graphml passed, but rather what the shell expands *.graphml to.

Therefore:

find . -name "*.graphml*"

See:

  • man find which says: "Don't forget to enclose the pattern in quotes in order to protect it from expansion by the shell."
  • A little more about Quoting from the Advanced Bash Scripting Guide.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.