在PowerShell中,如何加入对象数组的一个属性? [英] In Powershell, How to join one property of an array of objects?
本文介绍了在PowerShell中,如何加入对象数组的一个属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,我有在C 3个文件:\\ Z
For example, I have 3 files in c:\z
PS C:\z> dir | select name
Name
----
a.png
b.png
c.png
我要的是一个字符串。
What I want is a string.
a.png,b.png,c.png
a.png,b.png,c.png
感谢。
推荐答案
如果你想要一个字符串数组,你所要做的是:
If you want an array of strings, all you have to do is to:
dir | select -expand name
如果您希望与值一个字符串逗号分隔的:
If you want that as a single string with the values comma separated:
(dir | select -expand name) -join ","
这篇关于在PowerShell中,如何加入对象数组的一个属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文