Frank
Frank

Reputation: 45

Bind every line from two variables in a third variable in powershell

I got two variables, filled with:

$Var1:
Dog
Cat
Bird

$Var2:
makes wau
makes miau
makes beep

How can I mix both of them like:

$Var3 Dog makes wau Cat makes miau Bird makes beep

$Var3 = $Var1 + $Var2 dosen't work

Upvotes: 0

Views: 48

Answers (1)

CB.
CB.

Reputation: 60910

this is a rapid way (variables's lenght must be equal):

$i = 0 ; $var3 = $var1 | % { "$_ $($var2[$i])"; $i++ }

Upvotes: 1

Related Questions