How to find a string in files

Motivation:

Find a string in all files in a directory without having to install an external program that may decrease system security.

Method 1:

  1. Open a command prompt (cmd.exe)
  2. Go to the directory and
  3. Execute below command:
find /i "search string" *.*

/i: ignores the case of your search string.

Examples:

find /i "app files were copied" *.*
find /i "were copied" *.log

Method 2:

  1. Open a command prompt (cmd.exe)
  2. Go to the directory and
  3. Execute below command:
findstr /s "search string" *.*

/s: searches for each word in your search string.

or execute below command:

findstr /C:"search string" *.*

/C: searches for exact match of your search string .

Examples:

findstr /s "Integrated Security=true" *.cs
findstr /C:"app files were copied" *.log
(Visited 46 times, 1 visits today)

Leave a Reply