Aar*_*ron 16
假设一个名为"test.txt"的文件...要获得以Y结尾的行数,您可以这样做:
get-content test.txt | select-string Y$ | measure-object -line
Run Code Online (Sandbox Code Playgroud)
要获得以N结尾的行数,您可以这样做:
get-content test.txt | select-string N$ | measure-object -line
Run Code Online (Sandbox Code Playgroud)
希望有所帮助.
要在一行中获得两个计数:
gc .\test.txt | %{ if($_ -match "Y$|N$"){ $matches[0]} } | group
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
33416 次 |
| 最近记录: |