Fog Creek Software
Discussion Board

search word from a list in files


do you guys know any program which can do the following:

- in a text file I have a list of words, one in each line

- the program dig thru a directory/subdirectories/files and check each file if any of the word (from the first list) is present in the file

- then it gave me a result of match/no match.


Monday, September 15, 2003

.. talking about a windows environment  ..

Monday, September 15, 2003

Windows XP? :)

Monday, September 15, 2003

(This may not be quite what you're looking for.)

If it's Windows NT/2000/XP (that is, a version with Command Extensions) and you can do this from a Command Prompt window, the following command will provide a list of all files in a directory tree that contain the word, for each word in the first file (if it contains one word per line):

FOR /F %i in (wordlist.txt) DO FINDSTR /S /L /I /M "%i" *.*

Enter FOR /? and FINDSTR /? at a command prompt for more information on the /F switch for FOR and on the various switches for FINDSTR.

Philip Dickerson
Monday, September 15, 2003

There is a program called Perl which can do this fairly well.

Monday, September 15, 2003

I'll second perl. For any kind of text processing it really shines.

Matthew Lock
Monday, September 15, 2003

Feed grep from a script.

Tuesday, September 16, 2003

Umm why not grep with -f=FILE ?

Simon Lucy
Tuesday, September 16, 2003

A slightly less complicated and probably much faster variant of Philip's command:

  findstr /S /L /N /I /G:wordlist.txt *

Tuesday, September 16, 2003

*  Recent Topics

*  Fog Creek Home