Solved

Text file compare in powershell

Posted on 2013-06-19
2
380 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Synchronize a new Active Directory domain with an existing Office 365 tenant
A brief introduction to what I consider to be the best editor for PowerShell.
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…

813 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

11 Experts available now in Live!

Get 1:1 Help Now