the many functions of findstr
The June 6, 2016 tip of the night demonstrated how you can use the findstr Windows command to merge multiple text files. findstr can also be used to search through files - and there are a lot of options on how to run searches.
If you enter:
. . . at a command prompt you will see generated a description of how to structure a findstr search and a number of qualifiers that define the search.
I'm going to try to run different kinds of findstr searches on a folder containing some text files.
We begin with a text file, whitewhale.txt, at the root of a folder with the path C:\foofolder2
this folder has a subfolder with two files . . .
. . . one file with this content:
. . . and a second file with this content
when we enter the command:
findstr "moby" *.txt >C:\Process\results1.txt
. . . a text file is generated showing the line in the text file at the root of the home folder which includes the referenced string.
Including the reference /S in the command makes it search through subfolders in the home folder.
Using the reference in the command /R allows you to enter a regular expression search. Here we use the RegEx [0-9][0-9][0-9][0-9] . . . to search for lines with four digit numbers .
If we enter in the reference /V the findstr command will return lines that don't contain the referenced string.