用于搜索多种文件类型的 Unix find 命令的 Windows 等效项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6285148/
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 08:26:36  来源:igfitidea点击:

Windows equivalent for Unix find command to search multiple file types

windowsunixcommand-linefindls

提问by Soumen

While having a cygwin installed in windows gives most of unix command, still i was wondering how to search multiple filetypes in one command using windows "find" command.
ie: find . -name *.cpp -o -name *.h -o -name *.java

虽然在 Windows 中安装了 cygwin 可以提供大部分 unix 命令,但我仍然想知道如何使用 Windows“find”命令在一个命令中搜索多个文件类型。
IE: find . -name *.cpp -o -name *.h -o -name *.java

The above command gives me a list of all cpp, h & java, what will be the equivalent using the windows find?

上面的命令为我提供了所有 cpp、h 和 java 的列表,使用 windows find 的等效项是什么?

回答by JAB

This will locate all files with the given extensions in the current working directory and all subdirectories:

这将在当前工作目录和所有子目录中找到具有给定扩展名的所有文件:

dir *.cpp *.h *.java /b/s

See https://technet.microsoft.com/en-us/library/cc755121.aspxfor more info on using dir.

https://technet.microsoft.com/en-us/library/cc755121.aspx有关使用的详细信息dir

回答by Sreedhar GS

findstr /p /s /i .

findstr /p /s /i 。

above command searches for the given text in current directories and sub directories. /n will print the line numbers too.

上述命令在当前目录和子目录中搜索给定的文本。/n 也会打印行号。