설정된 오류 문자열과 일치하지 않는 모든 줄을 복사하려는 오류 로그 파일이 있습니다. 그래서 기본적으로 나는 인식 할 수없는 오류의 개별 파일을 만들고 있습니다. 나는 이것이 내가 파일에문자열을 기준으로 줄을 제거하십시오.
(Get-Content $path\temp_report.log) |
Where-Object { $_ -notmatch $error_1 } |
Out-File $path\uncategorised_errors.log
(Get-Content $path\temp_report.log) |
Where-Object { $_ -notmatch $error_2 } |
Out-File $path\uncategorised_errors.log
(Get-Content $path\temp_report.log) |
Where-Object { $_ -notmatch $error_3 } |
Out-File $path\uncategorised_errors.log
내 입력 파일을 읽기 위해 무엇을하고 무엇을
# Define all the error types that we need to search on
$error_1 = "Start Date must be between 1995 and 9999"
$error_2 = "SYSTEM.CONTACT_TYPE"
$error_3 = "DuplicateExternalSystemIdException"
$error_4 = "From date after To date in address"
$error_5 = "Missing coded entry for provider type category record"
모든 노하우 오류 유형을 정의
은 다음과 같이이다 :
15 Jul 2016 20:02:11,340 ExternalSystemId cannot be the same as an existing provider 15 Jul 2016 20:02:11,340 XXXXXXXXXXXXXXXXXXXXXXXXX 15 Jul 2016 20:02:11,340 ZZZZZZZZZZZZZZZZZZZZZZZZ 15 Jul 2016 20:02:11,340 DuplicateExternalSystemIdException 15 Jul 2016 20:02:11,340 DuplicateExternalSystemIdException 15 Jul 2016 20:02:11,340 SYSTEM.CONTACT_TYPE
내 아웃은 정확히 3 줄만 입력해야합니다.
15 Jul 2016 20:02:11,340 ExternalSystemId cannot be the same as an existing provider 15 Jul 2016 20:02:11,340 XXXXXXXXXXXXXXXXXXXXXXXXX 15 Jul 2016 20:02:11,340 ZZZZZZZZZZZZZZZZZZZZZZZZ
작품을 사용합니다. 나는이 작품을 얻었지만 당신의 대답은 더 우아하고 단 하나의 라이너 일뿐입니다. $ 결과 = Get-Content $ 경로 \ temp_report.log $ 결과 | Where-Object {$ _ -notmatch [regex] :: 이스케이프 ($ error_1)} | Set-Content $ path \ uncategorised_errors.log – zoomzoomvince