我的代码比较粗糙,适合初学者- $item = get-item C:\Users\12HS\a.txt;
- $i = 0;
- $str = "";
- Get-Content $item | ForEach-Object{
- if ($i % 2 -eq 0)
- {
- $str += $_ + ","
- }
- else
- {
- $str += $_ + "`r`n";
- }
-
- $i = $i + 1;
- }
- Out-File -FilePath t.TXT -Encoding ascii -InputObject $str;
- Get-Content t.TXT |Sort-Object |Out-File -FilePath OUT.TXT
- Remove-Item t.txt
-
复制代码
|