2013-07-16 3 views
1

이것은 내가 가지고있는 것이지만 그 것은 정확하지 않습니다.Powershell Compare-Object Trouble

(Get-Content C:\Users\U0146121\Desktop\Output.txt) | 
ForEach-Object { 
Compare-Object -referenceobject $_ -DifferenceObject $(get-content C:\Users\U0146121\Desktop\New folder\filenames.txt) -IncludeEqual 
} 

나는 현재 행을 비교하고 그 다음 새로운 txt 파일에 이름을 쓰는 경우가 filenames.txt 에 있는지보고 싶어요.

답변

1

이 콜렉션 $Ref = (Get-Content $origFile); $New = (Get-Content $NewFile);에 드롭 Comparing two arrays & get the values which are not common

유사 같은 각 파일의 내용을 보인다. 두 목록 모두 같은 수준의 경로 참조 (절대 경로와 깊이가 동일한 상대 경로)가 포함되어 있는지 확인하십시오. 그런 다음 두 컬렉션 객체를 비교합니다.

4

루프가 필요하지 않습니다.

Compare-Object -ReferenceObject (Get-Content .\Two.txt) -DifferenceObject (Get-Content .\One.txt) -IncludeEq 
ual | Where {$_.SideIndicator -eq '=='} | Select -ExpandProperty InputObject | Out-file C:\same.txt