Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We like to search many directories in a Windows environment with cygwin. We tried find . -name *.txt -print

but it complains the -print predicate. What is the correct command then ?

We only want matched files printed to console.

Thanks all

share|improve this question

It is complaining because you have not quoted the *.txt so the shell is expanding the pattern instead of passing it to find. In other words, let's say you are in a directory that contains these files:

 foo.txt bar.txt baz.txt

When you say find . -name *txt -print the wildcard (*) is expanded by the shell (bash probably) so what is passed to ffindis actually:

find . -name foo.txt bar.txt baz.txt -print

That's too many arguments and find complains. To get what you want, you need to quote the pattern you a re searching for (you also don't need the -print for what you are doing):

 find . -name "*txt"
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .