1
다음 스크립트는 두 개의 열을 반환합니다. 파일 이름을 나타내는 열 앞에 다른 열을 추가 할 수 있습니까?Powershell 그룹 여러 필드로
ls | select -First 10 |
% {
cat $_ | Select-String `, -AllMatches |
Select-Object LineNumber, @{n="Count"; e={$_.Matches.Count}} |
Group-Object Count |
% {
New-Object psobject -Property @{
"Count" = $_.Name
"LineNumbers" = ($_.Group | Select-Object -ExpandProperty LineNumber)
}
}
}
Count LineNumbers ----- ----------- 77 {1, 2, 3, 4...} 78 {7, 15, 22, 43...} 79 {16, 32, 37, 90...} 77 {1, 2, 3, 4...} 78 {7, 15, 22, 43...} 79 {16, 32, 37, 90...} 77 {1, 2, 3, 4...} 78 {7, 15, 22, 43...} 79 {16, 32, 37, 90...} 77 {1, 2, 3, 4...} 78 {7, 15, 22, 43...} 79 {16, 32, 37, 90...} 77 {1, 2, 3, 4...} 78 {7, 15, 22, 43...} 79 {16, 32, 37, 90...} 77 {1, 2, 3, 4...} 78 {7, 15, 22, 43...} 79 {16, 32, 37, 90...} 89 {1, 2, 3, 4...} 89 {1, 2, 3, 4...} 89 {1, 2, 3, 4...} 89 {1, 2, 3, 4...}