View Single Post
Old 07-06-2007   #1 (permalink)
Marco Shaw


 
 

Comparing files with compare-object

I've done everything I can think of to properly format a string to
compare between 2 files.

I've confirmed to my best of knowledge that one particular entry is
*exactly* the same in two files (same lenght, etc). However, I cannot
seem to get compare-object to find a match.

76# import-csv file1.csv|%{$_.'SN,CN'}|%{$_.replace(' (+)','')}|%{if($_
-match "some_user_removed"){$_}}|%{$_.length}
24
24
24
24
24
24
24
24
24
24
24
77# get-content file2.txt|%{$_.substring(13,56)}|%{$_.trimend()}|%{if($_
-match "some_user_removed"){$_}}|%{$_.length}
24

So above, I've confirmed (I think) that the string is exactly the same
lenght, however I can't get compare-object to indicate a match. One
file has 9,000 entries (lines), and the other has over 63,000.

I'm trying to get *only* the entries that match exactly between each
file. Something like this:

79# compare-object -ReferenceObject $(gc 1.txt) -DifferenceObject $(gc
2.txt) -includeequal -excludedifferent

InputObject SideIndicator
----------- -------------
test ==


80# gc 1.txt
test
testing
81# gc 2.txt
test

Any ideas? Gotchas I might be missing?
My System SpecsSystem Spec