是否有等效于“粘贴”(即水平文件串联)的 PowerShell?
Is there a PowerShell equivalent of `paste` (i.e., horizontal file concatenation)?
我想使用 PowerShell 横向 连接一堆 CSV 文件。 (在考虑可能的“重复”问题时,请注意“一堆”不是“两个”。)Linux paste 命令的 PowerShell 等价物是什么?
几个月前,我提交了 including a Join-Object
cmdlet to the standard PowerShell equipment #14994
的提案。
除了基于相关 属性 的更复杂的联接之外,我们的想法是还能够进行并排联接(通过省略 -On
参数)。
以此Paste
command in Linux为例:
$State =
'Arunachal Pradesh',
'Assam',
'Andhra Pradesh',
'Bihar',
'Chhattisgrah'
$Capital =
'Itanagar',
'Dispur',
'Hyderabad',
'Patna',
'Raipur'
安装
Install-Module -Name JoinModule
创建并排数组:
1..5 |Join $State |Join $Capital |% { "$_" }
1 Arunachal Pradesh Itanagar
2 Assam Dispur
3 Andhra Pradesh Hyderabad
4 Bihar Patna
5 Chhattisgrah Raipur
创建并排 对象:
1..5 |Join $State |Join $Capital -Name Number, State, Capital
Number State Capital
------ ----- -------
1 Arunachal Pradesh Itanagar
2 Assam Dispur
3 Andhra Pradesh Hyderabad
4 Bihar Patna
5 Chhattisgrah Raipur
连接(“粘贴”)两个对象:
$List = $State |Join $Capital -Name State, Capital
$Id = ConvertFrom-Csv @'
Id
A
B
C
D
E
'@
$Id |Join $List
Id State Capital
-- ----- -------
A Arunachal Pradesh Itanagar
B Assam Dispur
C Andhra Pradesh Hyderabad
D Bihar Patna
E Chhattisgrah Raipur
参考文献:
Join-Object script
Join-Object Module
- Project Site
- 另请参阅:In Powershell, what's the best way to join two tables into one?):
如果您支持Add a Join-Object cmdlet to the standard PowerShell equipment (#14994
)
的提案,请给个赞
我想使用 PowerShell 横向 连接一堆 CSV 文件。 (在考虑可能的“重复”问题时,请注意“一堆”不是“两个”。)Linux paste 命令的 PowerShell 等价物是什么?
几个月前,我提交了 including a Join-Object
cmdlet to the standard PowerShell equipment #14994
的提案。
除了基于相关 属性 的更复杂的联接之外,我们的想法是还能够进行并排联接(通过省略 -On
参数)。
以此Paste
command in Linux为例:
$State =
'Arunachal Pradesh',
'Assam',
'Andhra Pradesh',
'Bihar',
'Chhattisgrah'
$Capital =
'Itanagar',
'Dispur',
'Hyderabad',
'Patna',
'Raipur'
安装
Install-Module -Name JoinModule
创建并排数组:
1..5 |Join $State |Join $Capital |% { "$_" }
1 Arunachal Pradesh Itanagar
2 Assam Dispur
3 Andhra Pradesh Hyderabad
4 Bihar Patna
5 Chhattisgrah Raipur
创建并排 对象:
1..5 |Join $State |Join $Capital -Name Number, State, Capital
Number State Capital
------ ----- -------
1 Arunachal Pradesh Itanagar
2 Assam Dispur
3 Andhra Pradesh Hyderabad
4 Bihar Patna
5 Chhattisgrah Raipur
连接(“粘贴”)两个对象:
$List = $State |Join $Capital -Name State, Capital
$Id = ConvertFrom-Csv @'
Id
A
B
C
D
E
'@
$Id |Join $List
Id State Capital
-- ----- -------
A Arunachal Pradesh Itanagar
B Assam Dispur
C Andhra Pradesh Hyderabad
D Bihar Patna
E Chhattisgrah Raipur
参考文献:
Join-Object script
Join-Object Module
- Project Site
- 另请参阅:In Powershell, what's the best way to join two tables into one?):
如果您支持Add a Join-Object cmdlet to the standard PowerShell equipment (#14994
)