Open deepakganesh78 opened 3 hours ago
$file1 = "path/to/your/file1.xml" $file2 = "path/to/your/file2.xml"
$file1Content = Get-Content -Path $file1 $file2Content = Get-Content -Path $file2
$maxLines = [Math]::Max($file1Content.Length, $file2Content.Length)
$columnWidth = 80
Write-Host "Comparing files: $file1 and $file2"
for ($i = 0; $i -lt $maxLines; $i++) { $line1 = if ($i -lt $file1Content.Length) { $file1Content[$i] } else { "" } $line2 = if ($i -lt $file2Content.Length) { $file2Content[$i] } else { "" }
# Format the lines to the specified column width $formattedLine1 = $line1.PadRight($columnWidth) $formattedLine2 = $line2.PadRight($columnWidth) if ($line1 -eq $line2) { Write-Host "$formattedLine1 | $formattedLine2" -ForegroundColor Green } else { Write-Host "$formattedLine1 | $formattedLine2" -ForegroundColor Red }
}
Define the paths to your files
$file1 = "path/to/your/file1.xml" $file2 = "path/to/your/file2.xml"
Read the contents of the files
$file1Content = Get-Content -Path $file1 $file2Content = Get-Content -Path $file2
Find the maximum number of lines in either file
$maxLines = [Math]::Max($file1Content.Length, $file2Content.Length)
Define the width for each column
$columnWidth = 80
Write-Host "Comparing files: $file1 and $file2"
for ($i = 0; $i -lt $maxLines; $i++) { $line1 = if ($i -lt $file1Content.Length) { $file1Content[$i] } else { "" } $line2 = if ($i -lt $file2Content.Length) { $file2Content[$i] } else { "" }
}