I am trying to find all files, which does not contains a selected string. Find files which contains is easy:
gci | select-string "something"
but I do not have an idea how to negate this statement.
You want to use the "-L" option of grep : -L, --files-without-match Only the names of files not containing selected lines are written to standard output. Path- names are listed once per file searched. If the standard input is searched, the string ``(standard input)'' is written.
You can add the -l option to print just the file name; but this still prints the names of any file which contains any line which does not contain the pattern.
You can use Where-Object
;
gci | Where-Object { !( $_ | Select-String "something" -quiet) }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With