I want find string using dictionary file

Hello.

I need some help about script.

A.txt file has below text

==============================
blablablablablabla (0001) blablablabla
blablablablablabla (0001) blablablabla
blablablablablabla (0201) blablablabla
==============================

B.txt file has below text
==============================
0001
0030
0020 ...
more have number.
==============================

If has same charater in () on A.txt file compare B.txt, save conent C.txt

ex. get-content A.txt | compare-object B.txt | set-content C.txt <-----maybe like this script.

plz help me


August 24th, 2015 8:12am

You can reference the below code to write your own .

$Avals=Get-Content C:\A.txt
$Bvals=Get-Content C:\B.txt
$Regex='(\d+)'
foreach ($Aval in $Avals)
{
	$MatchValue= $Aval | Select-String -Pattern $Regex | Select-Object  {$_.Matches}
	$Value=$MatchValue.'$_.Matches'.Value
	foreach($Bval in $Bvals)
	{
		if($Value -eq $Bval)
		{
			$Value | out-file C:\C.txt -Append
		}
		
	}
	
}


Free Windows Admin Tool Kit Click here and download it now
August 24th, 2015 2:32pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics