Solved

Text file compare in powershell

Posted on 2013-06-19
2
377 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
Comment Utility
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
Comment Utility
Thanks alot.. it works..
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
This article will help you understand what HashTables are and how to use them in 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 setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

772 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

10 Experts available now in Live!

Get 1:1 Help Now