windows findstr ms-dos 命令不会搜索子目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9097034/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:10:12  来源:igfitidea点击:

findstr ms-dos command won't search sub directories

windowsfindstr

提问by DeadlyDan

I had to switch off my windows search indexing in Windows 7 as the old hard disk was constantly making noise with indexing switched on!

我不得不在 Windows 7 中关闭我的 Windows 搜索索引,因为旧硬盘在索引打开时不断发出噪音!

Now I want to use Windows command prompt to search for a specific text term within all files located within the current directory and sub directories

现在我想使用Windows 命令提示符在位于当前目录和子目录内的所有文件中搜索特定的文本术语

How do I use the Windiows command findstrto search subdirectories?

如何使用 Windows 命令findstr搜索子目录?

Currently, when I open a command prompt and change directory to C:\Users\Damien\Documents\Research\2012Julyand run the command findstr "thesis" *.tex /S, I get the following error :

目前,当我打开命令提示符并将目录更改为C:\Users\Damien\Documents\Research\2012July并运行命令时findstr "thesis" *.tex /S,出现以下错误:

FINDSTR: Cannot open /s

This command will search the current directory if I remove /S, but I want to be able to search for text within subfolders also.

如果删除 /S,此命令将搜索当前目录,但我也希望能够在子文件夹中搜索文本。

回答by jon

You need to put /Sat the beginning, i.e.:

你需要放在/S开头,即:

findstr /S "thesis" *.tex

From the built in help:

从内置帮助:

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[ ...]]

Your modifiers/switches, whatever they are called, need to come beforeyour pattern/string

你的修饰符/开关,无论它们叫​​什么,都需要放在你的模式/字符串之前

回答by PowerApp101

You have your arguments in the wrong order, try this:

你的论点顺序错误,试试这个:

findstr /S "thesis" *.tex