Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

Need to do a multi-key sort on a legacy text file that has no delimiters

$
0
0

I need to do a multi-key sort on a legacy text file that has no delimiters.

This is a relatively simple task on Unix but the Windows Command Shell cannot sort based on multiple keys - for example - column 5 thru 10 and 20 thru 30.

I decided to use Powershell to overcome this limitation but still struggling to find the answer.

So far i have attempted this but does not work:

$data = Get-Content  C:\data\test.txt | Sort-Object @{Expression={$_[16] - $_[59]},{$_[84] - $_[87]};Ascending=$true}

The data is like this - one long string:

CVMONLINREG_CUSTTC000000000000000000000003TC00000000000000032012040313202700000000800719CVMONLINTC000000000000000000000003

The shell hangs on running this and I have to kill the window.

Any suggestions are welcome at this point.

Thank you in advance


Viewing all articles
Browse latest Browse all 8411