FINDSTR – How to search text inside files

Maybe you need to find some text inside files. In all Windows versions you can use a command line program named FINDSTR.EXE. The syntax is the following:

FINDSTR [parameters] strings [[drive:][path]filename[ ...]]

There are many parameters to fine tune your search but the most used are:

  • /S = Searches for matching files in the current directory and all subdirectories.
  • /I = Specifies that the search is not to be case-sensitive
  • /L = Uses search strings literally

So, if you want to search the text “Mike” (case sensitive) inside all files with the extension .log in all subdirectories starting from the current directory just type:

FINDSTR /S "Mike" *.log

It’s important to understand how the /L parameter works. For example, consider this text:

“Mike is here”

Using this syntax:

FINDSTR /L "Mike.*"

will result in nothing found because the string is searched exactly as it is written including any wildcard or regular expression; instead using this syntax:

FINDSTR "Mike.*"

will find the string because the “.*” text inside the string is interpreted as a regular expression (any character).

Finally remember that FINDSTR works only with ASCII / UTF-8 files.

Leave a Reply

Your email address will not be published. Required fields are marked *