I am trying to check if a certain file has two strings. My test file is:
This is line1.
This is line2.
In real-time scenario for my application the strings line1 and line2 can be on the same or different lines or have one or more occurrences. The objective is to find if these string exist in the file.
Now, if I run the following command I expect OK to be printed but it doesn't.
cat test_file.sh | awk '$0 ~ /line1/ && /line2/ {print "OK"};'
Can someone please tell what is it that I need to change here.
a line with both line1 and line2and the second linea line with only line2?