the many functions of findstr part 2
top of page

the many functions of findstr part 2


Here's a follow up to last night's tip where I continue to discuss how to use findstr to collect lines with certain strings from multiple text files.

You can focus your findstr search so that it focuses only on the beginning or end of lines. We begin with one text file at the root of the source folder

. . . and these three text files in a subfolder

If we run this search with the /b qualifier to direct the search to the beginning of the line, and /s to search through subfolders:

findstr /b /s "the" *.txt >C:\Process\results5.txt

. . . we get these results, just the lines from the text files which begin with the word, 'the'.

You can also focus the search on the end of the lines and run RegEx searches:

findstr /e /r /s "[0-9][0-9][0-9][0-9]" *.txt >C:\Process\results11.txt

. . . we get these results with lines that end with four digits.

However note that if the last line of your text file contains the specific string it may not show up in the results.


bottom of page