Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find files which does not contains selected string

Tags:

powershell

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.

like image 974
Piotr Stapp Avatar asked Jul 30 '13 11:07

Piotr Stapp


People also ask

How do you find files that do not contain a string?

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.

Which command is used to print those lines of the file which don't contain the string or pattern?

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.


1 Answers

You can use Where-Object;

gci | Where-Object { !( $_ | Select-String "something" -quiet) }
like image 54
Joachim Isaksson Avatar answered Oct 27 '22 18:10

Joachim Isaksson