我发现了一篇关于想要在PowerShell中使用grep的用户的帖子.例如,
PS> Get-Content file_to_grep | Select-String "the_thing_to_grep_for"
Run Code Online (Sandbox Code Playgroud)
如何输出不是的行this_string
?
man*_*lds 52
Select-String有NotMatch
参数.
get-content file_to_grep | select-string -notmatch "the_thing_to_grep_for"
Run Code Online (Sandbox Code Playgroud)
Tim*_*ker 14
get-content file_to_grep | select-string "^(?!the_thing_to_grep_for$)"
Run Code Online (Sandbox Code Playgroud)
将返回不同的行the_thing_to_grep_for
.
get-content file_to_grep | select-string "^(?!.*the_thing_to_grep_for)"
Run Code Online (Sandbox Code Playgroud)
将返回不包含 的行the_thing_to_grep_for
.
gc file_to_grep | ? {!$_.Contains("the_thing_to_grep_for")}
Run Code Online (Sandbox Code Playgroud)
顺便说一下,这是区分大小写的比较。
归档时间: |
|
查看次数: |
26972 次 |
最近记录: |