我的问题与Windows命令shell有关,我知道PowerShell和其他可用的shell可以做到,但我想在这里学习细微差别。
我最近一直在挖掘并阅读有关“查找”的文档。具体而言,TechNet上注明了以下内容:
使用通配符
您不能在使用find命令指定的文件名或扩展名中使用通配符(*和?)。要在使用通配符指定的一组文件中搜索字符串,可以在for命令中使用find命令。
所以,我尝试了以下内容:
C:\Users\Public>echo some random apple text here > a.txt
C:\Users\Public>echo some more random text here > aa.txt
C:\Users\Public>echo some more random blah blah here > aaa.txt
C:\Users\Public>echo some more random crap here > aaa
C:\Users\Public>echo some more random apple here > aaa
然后我尝试了一些不同版本的find:
C:\Users\Public>find "apple" C:\
Access denied - C:\
C:\Users\Public>find "apple" C:\Users
Access denied - C:\USERS
C:\Users\Public>find "apple" C:\Users\Public
Access denied - C:\USERS\PUBLIC
C:\Users\Public>find "apple" C:\Users\Public\
File not found - C:\USERS\PUBLIC\
C:\Users\Public>find "apple" C:\Users\Public\*
---------- C:\USERS\PUBLIC\A.TXT
some random apple text here
---------- C:\USERS\PUBLIC\AA.TXT
---------- C:\USERS\PUBLIC\AAA
some more random apple here
---------- C:\USERS\PUBLIC\AAA.TXT
Access denied - C:\USERS\PUBLIC\DESKTOP
---------- C:\USERS\PUBLIC\DESKTOP.INI
Access denied - C:\USERS\PUBLIC\DOCUMENTS
Access denied - C:\USERS\PUBLIC\DOWNLOADS
Access denied - C:\USERS\PUBLIC\FAVORITES
Access denied - C:\USERS\PUBLIC\LIBRARIES
Access denied - C:\USERS\PUBLIC\MUSIC
Access denied - C:\USERS\PUBLIC\PICTURES
Access denied - C:\USERS\PUBLIC\RECORDED TV
Access denied - C:\USERS\PUBLIC\VIDEOS
C:\Users\Public>find "apple" C:\Users\Public\*.*
---------- C:\USERS\PUBLIC\A.TXT
some random apple text here
---------- C:\USERS\PUBLIC\AA.TXT
---------- C:\USERS\PUBLIC\AAA
some more random apple here
---------- C:\USERS\PUBLIC\AAA.TXT
Access denied - C:\USERS\PUBLIC\DESKTOP
---------- C:\USERS\PUBLIC\DESKTOP.INI
Access denied - C:\USERS\PUBLIC\DOCUMENTS
Access denied - C:\USERS\PUBLIC\DOWNLOADS
Access denied - C:\USERS\PUBLIC\FAVORITES
Access denied - C:\USERS\PUBLIC\LIBRARIES
Access denied - C:\USERS\PUBLIC\MUSIC
Access denied - C:\USERS\PUBLIC\PICTURES
Access denied - C:\USERS\PUBLIC\RECORDED TV
Access denied - C:\USERS\PUBLIC\VIDEOS
C:\Users\Public>
所以,我的结论:
我错过了什么?为什么文档说它不受支持(参考下面的内容)?
https://technet.microsoft.com/en-us/library/cc725655(v=ws.11).aspx(备注,第4章)