m0d*_*st0 5 powershell text-files
我正在使用一个大文本文件,我的意思是超过100 MB大,我需要遍历特定数量的行,一种子集,所以我正在尝试这个,
$info = Get-Content -Path $TextFile | Select-Object -Index $from,$to
foreach ($line in $info)
{
,,,
Run Code Online (Sandbox Code Playgroud)
但它不起作用.就像它只获得子集中的第一行一样.
我没有找到有关Index属性的文档,所以这是可能的还是我应该尝试使用不同的方法考虑文件大小?
PS> help select -param index
-Index <Int32[]>
Selects objects from an array based on their index values. Enter the indexes in a comma-separated list.
Indexes in an array begin with 0, where 0 represents the first value and (n-1) represents the last value.
Required? false
Position? named
Default value None
Accept pipeline input? false
Accept wildcard characters? false
Run Code Online (Sandbox Code Playgroud)
基于以上所述,'8,13'将为您提供两条线.您可以做的一件事是传递一组数字,您可以使用范围运算符:
Get-Content -Path $TextFile | Select-Object -Index (8..13) | Foreach-Object {...}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18900 次 |
| 最近记录: |