![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Compare two array Hi all, I have two identical arrays. $a = 0,1,2,3 $b = 0,1,2,3 I need to know if the arrays is identical if ($a -eq $b) this is doesn't working Thanks, Didi |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Compare two array I believe you can use compare-object. "Did" <didi10000@walla.co.il> wrote in message news:1173698692.087060.208650@64g2000cwx.googlegroups.com... > Hi all, > I have two identical arrays. > $a = 0,1,2,3 > $b = 0,1,2,3 > > I need to know if the arrays is identical > > if ($a -eq $b) this is doesn't working > > Thanks, > Didi > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Compare two array I have used compare-object successfully.$a = 1,2,3 $b = 1,3,4 $c = compare-object $a $b $c write-host "Objects inly exist in the first file" $c | % { if ($_.SideIndicator -match '<=') {$_.InputObject}} write-host "Objects inly exist in the second file" $c | % { if ($_.SideIndicator -match '=>') {$_.InputObject}} $a = "a","b","c" $b = "a","c","d","e" $d = compare-object $a $b $d write-host "Objects only exist in the first file" $d | % { if ($_.SideIndicator -match '<=') {$_.InputObject}} write-host "Objects only exist in the second file" $d | % { if ($_.SideIndicator -match '=>') {$_.InputObject}} regards, ktmd "Brandon Shell" wrote: > I believe you can use compare-object. > > "Did" <didi10000@walla.co.il> wrote in message > news:1173698692.087060.208650@64g2000cwx.googlegroups.com... > > Hi all, > > I have two identical arrays. > > $a = 0,1,2,3 > > $b = 0,1,2,3 > > > > I need to know if the arrays is identical > > > > if ($a -eq $b) this is doesn't working > > > > Thanks, > > Didi > > > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Compare two array FYI, when two arrays are the same, compare-object returns null. ktmd "ktmd" wrote: > I have used compare-object successfully.$a = 1,2,3 > $b = 1,3,4 > $c = compare-object $a $b > $c > write-host "Objects inly exist in the first file" > $c | % { if ($_.SideIndicator -match '<=') {$_.InputObject}} > > write-host "Objects inly exist in the second file" > $c | % { if ($_.SideIndicator -match '=>') {$_.InputObject}} > > > $a = "a","b","c" > $b = "a","c","d","e" > $d = compare-object $a $b > $d > > write-host "Objects only exist in the first file" > $d | % { if ($_.SideIndicator -match '<=') {$_.InputObject}} > > write-host "Objects only exist in the second file" > $d | % { if ($_.SideIndicator -match '=>') {$_.InputObject}} > > regards, > ktmd > > > > > "Brandon Shell" wrote: > > > I believe you can use compare-object. > > > > "Did" <didi10000@walla.co.il> wrote in message > > news:1173698692.087060.208650@64g2000cwx.googlegroups.com... > > > Hi all, > > > I have two identical arrays. > > > $a = 0,1,2,3 > > > $b = 0,1,2,3 > > > > > > I need to know if the arrays is identical > > > > > > if ($a -eq $b) this is doesn't working > > > > > > Thanks, > > > Didi > > > > > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Fast copy method of sub array (=array range) possible? | VB Script | |||
| How to create array without quotes? $array = (a,b,c) | PowerShell | |||
| Array indexing: Want to say "Item #2 through the rest of the array." | PowerShell | |||
| Stupid Array Tricks: Initializing an Array to a Certain Size | PowerShell | |||
| how to assign values to array and how to create array via variable | PowerShell | |||