2
1
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
2
1
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
4
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 ffind
is 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"
0
Could not get find
to work on Cygwin either. File not found
error all the time.
The problem was Windows has its own version:
$ which find
/cygdrive/c/Windows/system32/find
I solved it by typing /usr/bin/find everywhere but I suppose you could change path priorities or rename Windows' find.exe