How to find files with cygwin

cygwin;find

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

Best Answer

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"