Gnuwin32 port of “find”?

2019-07-29 15:40发布

Is there a problem with the Gnuwin32 port of "find"? It sort of works on my Windows XP command line, but I get blank stares when I try using file name pattern matching function. It's from "findutils-4.2.20" package. Had to rename to "gfind.exe" so Windows wouldn't confuse with CMD.EXE's "find".
Some samples from my Windows console:

C:\PROGRA~1\GnuWin32\doc\findutils\4.2.20\findutils-4.2.20>gfind .  
.  
./find.chm  
./find.dvi.gz  
./find.GID  
./find.hlp  
./find.html  
./find.pdf  
./find.ps.gz    

That works.
Again, the following works:

C:\PROGRA~1\GnuWin32\doc\findutils\4.2.20\findutils-4.2.20>gfind . -ls  
1970324837321105    0 drw-rw-rw-   2 cjohns89 0               0 Jun  11:34 .  
1688849860610677  128 -rw-rw-rw-   1 cjohns89 0          130729 Mar   2005 ./fin
d.chm  
1688849860610679   76 -rw-rw-rw-   1 cjohns89 0           74301 Mar   2005 ./fin
d.dvi.gz  
21673573207016133   20 -rw-rw-rw-   1 cjohns89 0           16826 Jun  21:05 ./fi
nd.GID  
1688849860610681  152 -rw-rw-rw-   1 cjohns89 0          154036 Mar   2005 ./fin
d.hlp  
1688849860610683  224 -rw-rw-rw-   1 cjohns89 0          226750 Mar   2005 ./fin
d.html  
1688849860610684  372 -rw-rw-rw-   1 cjohns89 0          379300 Mar   2005 ./fin
d.pdf  
1688849860610685  200 -rw-rw-rw-   1 cjohns89 0          201163 Mar   2005 ./fin
d.ps.gz  

But this doesn't do squat.

C:\PROGRA~1\GnuWin32\doc\findutils\4.2.20\findutils-4.2.20>gfind . -iname '*.pdf
' -ls  

It just returns to the prompt. Am I (a novice) just mistaken in my use of syntax or is there a bug?

2条回答
在下西门庆
2楼-- · 2019-07-29 16:23

Chuck wrote:

gfind . -iname '*.pdf ' -ls

It's better without the apostrophe, since the Windows XP command line is an MS-DOS one.

For example:

gfind . -iname *.pdf  -ls
查看更多
Summer. ? 凉城
3楼-- · 2019-07-29 16:25

A little wordy, but this link describes the issue. The short answer is that only double-quotes actually perform quoting in Windows' cmd.exe or command.exe.

Also, bear in mind that Windows expands *.pdf in the local directory first -- see Gnuwin32 find.exe expands wildcard before performing search.

查看更多
登录 后发表回答