Compare string doesn't compare each word

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of kishor kishor 1 day, 4 hours ago.

  • Author
    Posts
  • #71099
    Profile photo of kishor
    kishor
    Participant

    Hi,
    I have two text files with values in it as below;
    File A
    hello
    superman
    spiderman

    File B
    batman
    coolguy
    spiderman
    When I use command compare-object $A $B I get below result, please help as I need each word to be compared but here it takes file A words as whole line and gives result as 'Hello Superman spiderman' =>

  • #71113
    Profile photo of Matt Bloomfield
    Matt Bloomfield
    Participant

    Possibly a problem with the line break characters although I can't replicate it. How was the text file generated and how are you getting the files in $a and $b? Get-Content?

    • #71165
      Profile photo of kishor
      kishor
      Participant

      Hi Matt,
      Yes, I use get-content to get $A and $B. The compare works when I run command in below format 🙁
      compare-object $(get-content C:\Temp\Ref.txt) $(get-content C:\Temp\Des.txt) -IncludeEqual

      Thanks,
      Kishor

You must be logged in to reply to this topic.