Brian Hartsock's Blog

Join in the Pipeline

by bhartsock on Mar.04, 2009, under Uncategorized

Quick and dirty join function for powershell, that utilizes the pipeline.

function join 
{
	param($delimiter)
 
	begin { $strings = @() }
	process { $strings += $_ }
	end { [string]::Join($delimiter, $strings) }
}

The following now works:

> "Hello", "World" | join " "
Hello World

Post to Twitter Post to Digg Post to Facebook Post to Reddit

:

Leave a Reply

Post by day

March 2009
M T W T F S S
« Feb   Apr »
 1
2345678
9101112131415
16171819202122
23242526272829
3031