gpt4 book ai didi

powershell - 将输入列表分成几列

转载 作者:行者123 更新时间:2023-12-02 23:30:25 24 4
gpt4 key购买 nike

如何输入一个列表,并将内容显示在多列中,例如在三项之后;例子:

$carlist = "c:\temp\list-of-cars.txt"             # listing 10 cars               
$num-cols = 4

内容将是:
Car1          
Car2
..
Car9
Car10

$c = $carlist.count/$num-cols # some number of columns
write-host $carlist (something)

输出将是(基于列数:
Car1          Car4          Car7          Car10                                             
Car2 Car5 Car8
Car3 Car6 Car9

最佳答案

$cars = get-content "list-of-cars.txt"
$cars | Format-Wide {$_} -Column 4 -Force

或者,如果您更喜欢单线:
Get-Content .\list-of-cars.txt | Format-Wide {$_} -Column 4 -Force

关于powershell - 将输入列表分成几列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13367418/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com