开发者

Changing each entry in a list returned from powershell

开发者 https://www.devze.com 2023-01-25 05:18 出处:网络
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

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

精彩评论

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