I am using Gnuwin32 binaries on a Windows environment.
When I want to find files of a certain type, let's say PDF, I usually run:
find . -iname '*.pdf' -print
This works perfectly on any UNIX system.
find.exe . -iname "*.pdf" -print
But under Windows, having replaced single quotes with double-quotes, it only works when there is no pdf file in the current directory, otherwise the *
gets expanded.
Worse: when there is exactly one PDF file in the current directory, it will expand, there will be no syntax error and you will get wrong results.
I have tried escaping the *
with a caret, a backslash, a star itself, putting inside double quotes: nothing works for me.
Real example:
Okay, here are all my files:
C:\tmp>find . -type f
./a/1.pdf
./a/2.pdf
./a/aa/1.pdf
./b/1.pdf
./b/bb/1.pdf
./b/bb/2.pdf
Good behaviour, wildcard was not expanded
C:\tmp>find . -iname "*.pdf"
./a/1.pdf
./a/2.pdf
./a/aa/1.pdf
./b/1.pdf
./b/bb/1.pdf
./b/bb/2.pdf
C:\tmp>cd a
Caution, inconsistent behaviour, wildcard was expanded:
C:\tmp\a>find . -iname "*.pdf"
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
C:tmp\a>cd ..\b
Caution, inconsistent behaviour, wildcard was expanded :
C:\tmp\b>find . -iname "*.pdf"
./1.pdf
./bb/1.pdf
Thank you
*
to get expanded? If not, how do you think find shows you the results? – Nutationfind
to have argv[3] equal to{'*','.','p','d','f'}
. Find is adult enough to interpret the jokers. – Barometrograph./a.pdf
,./b/a.pdf
,./b/b.pdf
; I runfind . -iname "*.pdf"
. Cmd expands it tofind . -iname a.pdf
, and eventually I do not get./b/b.pdf
in my results. Of course with a Unix shell,find . -iname '*.pdf'
gets me all pdf files. – Barometrographfind . -iname "*.pdf"
and i don't have problems. It will show me all my pdf files... – Nutation