70

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

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

2 Answers 2

105

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.aspx for more info on using dir.

Sign up to request clarification or add additional context in comments.

15 Comments

also this command is not working in windows7 somehow .. or maybe i am wrong. Also i found tree might be better alternative than find in windows.
@Soumen: Then don't say 'windows "find" command', but 'the Windows equivalent to unix's "find" command'. Anyway, updated my answer with something that should be closer to what you want. (If I'm not mistaken, tree doesn't allow you to restrict results to files with specific extensions.)
And if you want to emulate the very common find . -name \*.cpp | wc -l *nix command idiom, you can use dir *.cpp /b/s | find /c /v "". See Raymond Chen's post for details.
How to narrow this down to subdir? find . -name "*Test.php" src
@DrPhil I tracked it down to devblogs.microsoft.com/oldnewthing/20110825-00/?p=9803. Just from the old URL and a little time. You could also have done that :)
|
-3

findstr /p /s /i .

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

1 Comment

This is similar to grep, not find.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.