find | parallel 'perl -lane '\'' print "$ARGV: $_" if $. == 1 and /searchStr/i '\'' {}' Another idea to try and speed things up is putting available cores and threads to work: that's what GNU parallel is for. This example sports perl, but it does the same as awk in 3. above. Here's a command breakdown:
find look for files in the current directory and its subdirectories. You can specify a different directory to look in and a file pattern or extension to filter on: find /cygdrive/c/Directory/To/Search -iname "*.txt".
| "pipe", i.e. feed the list of results to the next command.
parallel execute the next command in parallel.
perl scripting language that excels at text file manipulation, can replace sed or awk.
-lane useful set of switches for perl one-liners.
'\'' escaped apostrophe, needed since we already opened an apostrophe set after parallel.
print "$ARGV: $_" print the filename ($ARGV), a colon, a space and the full line ($_).
if only execute the previous instruction if the following condition(s) are met.
$. == 1 line number ($.) is equal to one (1), i.e. we are looking at the first line of the file.
and the following condition must be met, too.
/searchStr/i the line being examined contains the text searchStr, case-insensitively.
'\'' another escaped apostrophe marks the end of the perl instruction.
{} this is going to be substituted by parallel with each of the filenames passed on by find.
' end of the parallel instruction.