2011-11-21 11 views

risposta

13
get-content file_to_grep | select-string "^(?!the_thing_to_grep_for$)" 

restituirà le linee che sono diversi da the_thing_to_grep_for.

get-content file_to_grep | select-string "^(?!.*the_thing_to_grep_for)" 

restituirà le linee che non fanno contengonothe_thing_to_grep_for.

49

Select-String ha il parametro NotMatch.

get-content file_to_grep | select-string -notmatch "the_thing_to_grep_for" 
+0

Anche questa risposta era giusta !!! DOUBLECHEKZ! – Chrips

+6

Questa dovrebbe essere la risposta corretta accettata. – Scrat

+1

Risposta semplice e corretta. – hdoghmen

2
gc file_to_grep | ? {!$_.Contains("the_thing_to_grep_for")} 

che è confronto case-sensitive proposito.

Problemi correlati