Felix Urbasik

Felix Urbasik

Welcome to my personal knowledge archive.

← Back to Index

Searching on Windows

The main purpose of this blog is to record useful knowledge in a place where I (or others) can find it easily. In this case it's a Windows CMD command for finding strings in files. The Windows command line was designed for computers of another age, therefore it's very fast on modern machines. Unbeatable even!

File search

When it comes to searching files, nothing is faster than the good old dir command:

C:\> dir /b/s *needle*

String search

So, here's how to seach for needle in any *.h or *.cpp files, the quotes are required:

C:\> findstr /spin /c:"needle" *.cpp *.h

And that's basically it for now. When I have another idea I'll post it here.


I just learned that UTF-8 files that begin with the UTF-8 byte order mark will not be scanned by this command because the parameter /p prevents scanning files with non-printable characters. But when you filter by file extension anyways, you can omit that parameter. So the new command would be:

C:\> findstr /sinc:"needle" *.cpp *.h