I’m trying to count all text files in a folder that contains all strings in a set of strings, i.e. basically an AND-operator. The order of the string in each file may way and preferably I’m looking for a one-liner.
I.e. I’m trying to accomplish something like:
(Get-ChildItem -filter "file*" C:\temp |
Select-String -Pattern @(“str1", "str2")).Count
but with the difference that the above statement counts all files containing either “str1” or “str2” but I’m trying to do an AND-operation instead of an OR, thus count only files that contains both “str1” and “str2”.
Regards, Ola
This perhaps can do the job with a
-ANDoperator :