Solved

Text file compare in powershell

Posted on 2013-06-19
2
379 Views
Last Modified: 2013-06-19
I have two text files..  i need to compare that text files with powershell. Please help me.

File 1  having below contents

01hw1
01hw2
01hw3
01hw4

File 2 having below contents

01hw1
01hw3
01hw5
01hw6


and i need  output like

Added entries :

01hw5
01hw6

Deleted entires:

01hw2
01hw4
0
Comment
Question by:aarun_tcs
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39259129
cls
$files1 = gc c:\temp\test\1.txt
$files2 = gc c:\temp\test\2.txt
$groups = Compare-Object $files1 $files2 | Group-Object -Property SideIndicator
Write-Output "Added Entries"
$groups[0].Group | %{Write-Output $_.inputobject}
Write-Output "" 
Write-Output "Deleted Entries"
$groups[1].Group | %{Write-Output $_.inputobject}

Open in new window

0
 

Author Comment

by:aarun_tcs
ID: 39259172
Thanks alot.. it works..
0

Featured Post

Want to promote your upcoming event?

Attending an event? Speaking at a conference? Or exhibiting at a trade show? Easily inform your contacts by using a promotional banner in your email signature. This will ensure your organization’s most important contacts are in the know.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now