Extract line containing specific words
hi,
i extract lines form text file containing specific words based on external text file contains specific words keep. (!)
my source file :
accountname: toto01
changetype property newvalue
---------- -------- --------
metadata sps-personalsiteinstantiationstate
metadata sps-feedidentifier
modify sps-personalsiteinstantiationstate 2
accountname: toto02
changetype property newvalue
---------- -------- --------
modify personaladdress 715 taire
modify sps-lastkeywordadded 24.06.2016 00:00:00
modify personaladdress 715
metadata civilstatusother
add civilstatusother sdfsdsddsd
modify personaladdress 715 ru
accountname: toto03
changetype property newvalue
---------- -------- --------
modify workphone +01 444 721 92 76
my third party file contains:
accountname:
modify personaladdress
add civilstatusother
modify workphone
my destination file :
accountname: toto01
accountname: toto02
modify personaladdress 715 taire
modify personaladdress 715
add civilstatusother sdfsdsddsd
modify personaladdress 715 ru
accountname: toto03
modify workphone +01 444 721 92 76
is possible in powershell ?
thank in advance help
hi fixit,
sure possible, simple:
$list = get-content "thirdparty.txt" $pattern = $list -join "|" get-content "source.txt" | select-string -pattern $pattern | out-file "destination.txt"
what dynamically creating regex pattern reading matches file , joining them "or"-operator. read source file , select matches.
cheers,
fred
there's no place 127.0.0.1
Windows Server > Windows PowerShell
Comments
Post a Comment