Comparing text files and adding new text
hi wondering if can have 2 text file want compare.
one final 1 , 1 temporary
the temp file have new information in , want write these changes final file need insert them in same place in temp file example if final file has
1
2
3
6
7
and temp file has
1
2
3
4
6
7
to insert number 4 in @ line 4 mirrors temp file final file edited out side of script information needs remain intact , new lines added in correct location in file there may more 1 change in temp file great
well compare not sure order
$a = get-content ".\test1.txt" $b = get-content ".\test2.txt" compare-object -referenceobject $a -differenceobject $b -includeequal | where-object { $_.sideindicator -eq '=>' -or $_.sideindicator -eq '=='}` | foreach-object { $_.inputobject } | out-file -filepath final.txt -width 150
Windows Server > Windows PowerShell
Comments
Post a Comment