Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to join array in pipe

I wish to join the result from a pipe.

I tried using -join

PS> type .\bleh.log | where { $_ -match "foo"} | select -uniq | $_ -join ','

But that give me this error :/

Expressions are only allowed as the first element of a pipeline.

like image 635
Snæbjørn Avatar asked Nov 18 '15 08:11

Snæbjørn


1 Answers

You could try this :

@(type .\bleh.log | where { $_ -match "foo"} | select -uniq) -join ","

You would need a Foreach-Object (alias %) after the last pipe to have the $_ variable available but it wouldn't help since it holds a single cell value (for each loop iteration).

like image 157
sodawillow Avatar answered Nov 10 '22 12:11

sodawillow