开发者

Changing each entry in a list returned from powershell

I have a list of paths (filtered by special criteria). I want to mutate each entry in this list, but can't find a way (I think it's immutable). What's th开发者_StackOverflow社区e best way of going about this?

Thanks


I guess you have some collection, not only list (probably array).

PS> $myList = 'first','second','third'

You can mutate the collection by indexing or just by creating new array like this:

PS> $myList[1] = '2nd'
#or
PS> $myList | % { $_.Substring(0,2) }
  fi
  se
  th
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜