I have a big log file which I am trying to scan it for a particular words. In general, I will have few words which I need to grep on my big log file and print out the line which contains those words.
I know how to do simple grep on a file. Suppose if my file name is abc.log
and I need to find a line which contains word "hello" then I always do it like this and it prints out the line for me.
grep -i "hello" abc.log
But I don't know how to do the grep for combination of words. Meaning I would have list of words and I will scan my abc.log file for all those words and I will print out the lines which contains those words individually.
#!/bin/bash
data="hello,world,tester"
# find all the lines which contains word hello or world or tester
So in my above shell script I will split my data variable and look for hello word in abc.log so any line which contains hello word, I will print it out and similarly with world and tester as well.
I am trying to make this pretty generic so that I just need to add my list of words in the data variable without touching the actual logic of grepping the logs.