I have a large log file that I am trying to scan for specific words. In general, I will have a few words that I need to grep on my large log file and print a line containing these words.
I know how to make simple grep in a file. Suppose if my file name is abc.log and I need to find a line containing the word βhelloβ then I always do it like this and it prints the line for me.
grep -i "hello" abc.log
But I do not know how to make grep for a combination of words. Meaning I would have a list of words, and I will scan my abc.log file for all these words, and I will print lines containing these words individually.
#!/bin/bash data="hello,world,tester"
So, in my shell script, I would split my data variable and look at the word hello in abc.log so that any line containing the word hello, I print and similarly with the world and the tester.
I am trying to make this pretty general, so I just need to add my list of words to the data variable without touching the actual logic of grepping logs.
source share