Search a file for a list of words
by helloall from LinuxQuestions.org on (#4Y3MX)
Hi.
I would like to ask a question. I am trying to write a bash script.
I have a file filters.txt which contains words:
Word1
Word2
Word3
And a second file myinput.html
I want to search myinput.html for all words (Word1/Word2/Word3) and then make a new file with the matches like myoutput.txt
Something like:
grep -F -f /scripts/filters.txt /scripts/myinput.html > /scripts/output.txt
Now my question is this...
How can i do that without case sensitive, with wildcards and search more than one word per line?
Example:
Lets say i have this as myinput.html:
Hello I Am Newbie
blah blah
More And More
I Can't find anything
You will not find this one
I want my filters.txt to be like:
*Hello?I?Am?Newbie* #This should find the first one
#Where * means i don't know what could be before Hello.
#Where ? means only one character which is unknown to me. (Could be Hello.I.Am.Newbie for example)
*can?t* #This should find the last one.
bla bla
*More*And* #This should fine the 3rd one.
Thanks in advance.


I would like to ask a question. I am trying to write a bash script.
I have a file filters.txt which contains words:
Word1
Word2
Word3
And a second file myinput.html
I want to search myinput.html for all words (Word1/Word2/Word3) and then make a new file with the matches like myoutput.txt
Something like:
grep -F -f /scripts/filters.txt /scripts/myinput.html > /scripts/output.txt
Now my question is this...
How can i do that without case sensitive, with wildcards and search more than one word per line?
Example:
Lets say i have this as myinput.html:
Hello I Am Newbie
blah blah
More And More
I Can't find anything
You will not find this one
I want my filters.txt to be like:
*Hello?I?Am?Newbie* #This should find the first one
#Where * means i don't know what could be before Hello.
#Where ? means only one character which is unknown to me. (Could be Hello.I.Am.Newbie for example)
*can?t* #This should find the last one.
bla bla
*More*And* #This should fine the 3rd one.
Thanks in advance.