Link to home
Start Free TrialLog in
Avatar of johnnyjonathan
johnnyjonathan

asked on

Looking for a script to compare 3 text files and run a command in case they match

Hi,
I'm looking for a script (could be vb\power shell\batch) to compare between 3 text files, they only have a numeric value in them, in case all files match, then run a command

Any advise please?
Avatar of Martin Tarlink
Martin Tarlink
Flag of United States of America image

Go ahead and use DiffMErge software it is nice GUI
http://www.sourcegear.com/diffmerge/
Please try this

Note sure what really required, from your question a you might looking for this, or you can derive the one you require from this
================================================================
$a=get-content .\files1.txt
$b=get-content .\files2.txt
$c=get-content .\files3.txt

$first = Compare-Object $a $b
$last = Compare-Object $a $c

if ($first -eq $Null -and $last -eq $Null)
{

            Write-Host "All file match"
            #{Execute your Command here}
}

elseif ($first -eq $Null)
{

Write-host "last two files not matching"
}
else       
{
Write-host "First two file not matching"
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of johnnyjonathan
johnnyjonathan

ASKER

Perfect!
Thank you!