Solved

Text file compare in powershell

Posted on 2013-06-19
2
382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

Question has a verified solution.

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

This article will help you understand what HashTables are and how to use them in PowerShell.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
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…

696 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