This question already has an answer here:
I need to check if two (specified) words exist on any line in a text file. There are no limits for the characters of the words. For example:
I want to find lines of a text file that contain the two words “cat” and “elephant” together (i.e., on the same line; not necessarily side-by-side):
Cat is smaller than elephant Elephant is larger than cat Cats are cute! Elephants are very strong Cat and elephants live in different environments cats are friendly
In the previous examples, how can I find the lines containing both words?
Cat is smaller than elephant Elephant is larger than cat Cat and elephants live in different environments
I tried grep and awk with no hope. The problem is there are words that have upper and lower case, so how can I match for both words regardless of their letter status!?