How to loop in powershell where loop value is combination of string and variable -
$ a1 = match-content-path "file path a1" $ B1 = get-content-path " File path B1 "$ A2 = match-content-path" file path A2 "$ b2 = find-content-path" file path B2 "$ A3 = find-content-path" file path A3 " $ B3 = get-content-path "file path B3" # I want to select AI and BE in every loop ($ i-5 5) {foreach ("$ 1" here in $ 1) {$ Found = $ false foreach ($ line2 in "what to do")) {if ($ line1 -q $ line2) {write-host "do something"}} I wanna knowWhat I should do is "what to do here," so that a) first loop select a1 and b1 files, b) select the second loop A2 and B2 files and similarly
Hello, The code below is taking too long to print big files, what is different in each file Can you suggest some customization?
$ i = 1 while ($ i -le 7) {$ t1 = Get-content -Path $ (($ oldpath) + ($ (Get-Variable) "F $ i" ).) + ($ Format) $ t2 = Get-content -Path $ (($ NEWpath) + ($ (Get-Variable "F $ i"). Value) + ($ format)) $ List1 = new -object 'system.collections.generic.list [string]' $ list2 = new-object 'system.collections.generic.list [string]' $ listhared = new-object 'system.collections.generic list [string] $ $ = $ False foreign currency ($ 1 $ in $ 1) {$ mil = $ wrong foreign currency ($ 2 dollar in $ 2) if (-NOT $ not found) {$ list1.add ($ line1)}} ($ $ Line 2 in $ 2) ($ line 2 in $ 2) {$ $ = $ false foreach ($ 1 $ $ 1) if (-Note not found) {$ list2.add ($ line 2)}} Write - host "Things in the new txt file:" -Furfood "Magenta" $ List 1 Write-Host "Things Only in Old Textile File:" -Fruffield "Magenta" $ List 2 Remove-Variables "T1 "Extract-variable" T2 "$ i ++}
for example You can use:
Go-Variable - the name "A $ i" | Choose value but it seems like a bad practice to use one variable for each file ...
but you do not specify paths or files while comparing If done, combine the files with Get-content . Update:
$ i = 1 while ($ i-5 5) {$ file1 = Get-Content -Path $ ($ (Get-Variable "A) $ I ") Value. $ File2 = get-content -Path $ ($ (gate-variable" B $ i "). Value) foreach ($ line1 $ in file1) $ $ = $ false foreach ($ line2 $ file2 ) {If ($ line1 -q $ line2) {write-host "Something"}}} Remove-variable "file1" -exclude-variable "file2" $ I ++} This every variable
Comments
Post a Comment