Reputation: 825
Is there a way to search for a defined string within several thousand text files and to print the names of the files that have a match?
Upvotes: 2
Views: 1423
Reputation: 67216
findstr /M "searched string" *.txt > matchingFiles.out
From findstr /?
documentation:
/M Prints only the filename if a file contains a match.
Upvotes: 3
Reputation: 643
Not sure which OS platform to be answered for,
But Linux/Unix systems can have the following command used for this purpose.
find . -name '*.ext' -type f | xargs fgrep 'pattern to be searched'
This will search the files starting from current directory and check for the 'pattern to be searched'. The file name pattern with wildcard can be applied where I have used '*.ext'
Upvotes: 0