PoshCode Logo PowerShell Code Repository

A Compare-Object Bug (modification of post by view diff)
embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1069"></script>download | new post

Demo for unexpected output of Compare-Object

  1. # I want do demonstrate a Compare-object bug
  2. # Bernd Kriszio - http://pauerschell.blogspot.com/
  3.  
  4. 1, 2, 3, 4, 5 > .\textfile_a.txt
  5. 1, 2, 4, 5, 6 > .\textfile_b.txt
  6. cat .\textfile_a.txt
  7. cat .\textfile_b.txt
  8. compare-object (gc .\textfile_a.txt) (gc .\textfile_b.txt) -inc
  9. <#yields
  10. InputObject                                SideIndicator                            
  11. -----------                                -------------                            
  12. 1                                          ==                                        
  13. 2                                          ==                                        
  14. 4                                          ==                                        
  15. 5                                          ==                                        
  16. 6                                          =>                                        
  17. 3                                          <=                                        
  18.  
  19. I think it has to be
  20. InputObject                                SideIndicator                            
  21. -----------                                -------------                            
  22. 1                                          ==                                        
  23. 2                                          ==                                        
  24. 3                                          <=                                        
  25. 4                                          ==                                        
  26. 5                                          ==                                        
  27. 6                                          =>                                        
  28. #>

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me