Hi i searched few older posts but didnt find exact solution. so posting new question.
I need a single a windows command to search two words using AND condition. Will findstr works for combination of words?
im searching for WORD1 followed by WORD2.( not in reverse. word2 followed by word1 or single word).
Below one is sample file contents:
TABLEA
insert
INSERT TABLEA
update tableA
upsert tableb
insert into tableA
update staging.tableA
insert into staging.tableA
-- insert into staging.tableA
test insert staging.tableA
tableA insert
tableA select insert
Desired Search Output: prints the filename when match is found. fr example, word1=insert and word2=tableA. below are the sample search results
INSERT TABLEA
insert into tableA
insert into staging.tableA
-- insert into staging.tableA
test insert staging.tableA
And i have thousands of files to search and huge in size. i need filenames which contains the match of two words.
I tried using findstr command. but not succeeded.Is there any equivalent command to use in batch file?
Thanks in advance.
Best Answer
Given your exemple i was able to produce the expected result :
Assuming :
sample.txt
contains the sample file content you providedAND
order ("insert.*.tableA"
)/I
) to matchINSERT TABLEA
I've not tested every use cases, but should be a good start for you to improve.
From now, it's up to you to parse some rules files and pass variables to the command above, this is another story but not a
findstr
issue.