In bash
I wrote
echo prefix{t1,t2,t3}suffix
and got
prefixt1suffix prefixt2suffix prefixt3suffix
Is something like this present in PowerShell? List expantion I mean.
In bash
I wrote
echo prefix{t1,t2,t3}suffix
and got
prefixt1suffix prefixt2suffix prefixt3suffix
Is something like this present in PowerShell? List expantion I mean.
There is no automatic expansion, but you can do it easily with ForEach-Object
cmdlet or array's ForEach
method in PS 4 and higher:
't1', 't2', 't3' | ForEach-Object {'prefix' + $_ + 'suffix'}
@('t1', 't2', 't3').ForEach({'prefix' + $_ + 'suffix'})
A couple of other ways are:
't1', 't2', 't3' | % {"prefix$($_)suffix"}
and
't1', 't2', 't3' | % {'prefix{0}suffix' -f $_}