I have two lists stored in variables: $list1
and $list2
, for example:
$list1
:
a b c d
$list2
:
1 2 3 4
How do I merge them together line by line so that I end up with:
a1 b2 c3 d4
I have tried using array (@) but it just combines them one after the other, not line by line, example:
$list1 = @(command)
$list1 += @($list2)
If you prefer pipelining, you can also do it in one line:
0 .. ($list1.count -1) | ForEach-Object { $list1[$_]+$list2[$_] }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With