我不得不在 Windows 7 中关闭我的 Windows 搜索索引,因为旧硬盘在打开索引时不断发出噪音!
现在我想使用 Windows 命令提示符在当前目录和子目录中的所有文件中搜索特定的文本术语
如何使用 Windows 命令 findstr 搜索子目录?
目前,当我打开命令提示符并将目录更改为 C:\Users\Damien\Documents\Research\2012July
并运行命令 findstr "thesis"*.tex/S
,我收到以下错误:
FINDSTR: Cannot open /s
如果我删除/S,此命令将搜索当前目录,但我也希望能够在子文件夹中搜索文本。
最佳答案
需要在开头加上/S
,即:
findstr /S "thesis" *.tex
来自内置帮助:
C:\>findstr /?
Searches for strings in files.
FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file]
[/C:string] [/G:file] [/D:dir list] [/A:color attributes] [/OFF[LINE]]
strings [[drive:][path]filename[ ...]]
你的修饰符/开关,无论它们叫什么,都需要出现在你的模式/字符串之前
关于windows - findstr ms-dos 命令不会搜索子目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9097034/