Skip to main content
format; edited title to be more inline with the question
Source Link
don_crissti
  • 85.6k
  • 31
  • 234
  • 262

How to grep through multiple files using multiple inputs which are alsolines from two input files as start and end of pattern?

Hi I would like to write a simple script that would use grep to search through a list of files. The current code looks something similar to this:

a= file1.txt

b= file2.txt

for

do

grep '$a.*$b' /root/listoffiles/*php >> found.txt

a= file1.txt 

b= file2.txt

for

do

grep '$a.*$b' /root/listoffiles/*php >> found.txt

done

file1file1 and file2file2 are both word lists. So this would search through the destination having multiple criteria.For For example $a$a could be "hello" and b$$b "world" or the second line could be "red" and "tshirt". If it finds anything with two matching criteria then it would just save it into the file. The loop that I am using is not working and not efficient enough. I would like to get only the results for meeting criteria. Any suggestions? Thanks in advance

How to grep through multiple files using multiple inputs which are also files?

Hi I would like to write a simple script that would use grep to search through a list of files. The current code looks something similar to this:

a= file1.txt

b= file2.txt

for

do

grep '$a.*$b' /root/listoffiles/*php >> found.txt

done

file1 and file2 are both word lists. So this would search through the destination having multiple criteria.For example $a could be "hello" and b$ "world" or the second line could be "red" and "tshirt". If it finds anything with two matching criteria then it would just save it into the file. The loop that I am using is not working and not efficient enough. I would like to get only the results for meeting criteria. Any suggestions? Thanks in advance

How to grep through multiple files using lines from two input files as start and end of pattern?

I would like to write a simple script that would use grep to search through a list of files. The current code looks something similar to this:

a= file1.txt 

b= file2.txt

for

do

grep '$a.*$b' /root/listoffiles/*php >> found.txt

done

file1 and file2 are both word lists. So this would search through the destination having multiple criteria. For example $a could be "hello" and $b "world" or the second line could be "red" and "tshirt". If it finds anything with two matching criteria then it would just save it into the file. The loop that I am using is not working and not efficient enough. I would like to get only the results for meeting criteria. Any suggestions?

Source Link
Stephen
  • 155
  • 2
  • 11

How to grep through multiple files using multiple inputs which are also files?

Hi I would like to write a simple script that would use grep to search through a list of files. The current code looks something similar to this:

a= file1.txt

b= file2.txt

for

do

grep '$a.*$b' /root/listoffiles/*php >> found.txt

done

file1 and file2 are both word lists. So this would search through the destination having multiple criteria.For example $a could be "hello" and b$ "world" or the second line could be "red" and "tshirt". If it finds anything with two matching criteria then it would just save it into the file. The loop that I am using is not working and not efficient enough. I would like to get only the results for meeting criteria. Any suggestions? Thanks in advance