-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDiff_2_File.ps1
More file actions
46 lines (40 loc) · 2.71 KB
/
Diff_2_File.ps1
File metadata and controls
46 lines (40 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#this script find difference between two text files
Write-Host "Enter the file1 name:"
$file1=Read-Host #get first file name
Write-Host "Enter the file2 name"
$file2=Read-Host #get 2nd file name
if(Test-Path $file1) #test file exits or not
{
if(Test-Path $file2) #test file exits or not
{
Write-Host "==========================================="
Write-Host "These words are in file2 but not in file1 :"
Write-Host "==========================================="
$cont = Get-Content $file2 #read file
foreach ( $i in $cont)#get line
{
$bool = "false" #boolian testing variable
$cont2 = Get-Content $file1 #read file
foreach($j in $cont2) #get line
{
if($j -eq $i) #test file1 with file2
{
$bool = "true"
}
}
if($bool -eq "false")#check test result
{
Write-Host $i #print those words that not inside of file1
}
}
}
else
{
Write-Error "File2 not found!"
}
}
else
{
Write-Error "File1 not found!"
}
Read-Host "Press ENTER to continue........................."