What you show as code means:
print a file name when a single record has 3 out of 4 search strings.
The example that works tells me that this is not what is in the data, nor is it what you mean. I am guessing that what you want is a list of files that have 3 out of 4 sprinkled somewhere in the file, not all on the same line. This works in ksh:
For pravin27's code, if the input txt file has two b1b, but no d1d, it will also export the filename. If there are more b1b, d1d, (more than 2), if will not list it.
Thanks a lot for everyone. test script is working.. I am testing it in a larger context.
I am hoping there is no better way of doing this kind multiple string searching sprinkled in a file conditionally. If there is one please share.
---------- Post updated at 09:42 AM ---------- Previous update was at 09:38 AM ----------
becket,
What you are trying to help me with is searching for multiple strings in the file Names. But my question was to find them in the file contents.
Please read the question and test data I gave carefully.
Well it is quite understandable since the OP's post is a bit contradictory IMO. I am assuming the OP is looking for what Jim suggested in post #2. Then this could be used in the find exec: