Coderifous
Programmer
Hey all,
I'm a perl guy, and not really a stranger to unix, not a guru either (about to be obvious).
I'm needing to sort some data, and I'm getting screwy results. I'll post a line or two of notional data, and then the sort command I'm using.
Notional Data: (substitut dashes for spaces; s/-/ /g
Remember: There are no dashes, I put them here to keep count of spaces.
Now imagine have a gig's worth of data (single file) in that shape that needs to be sorted.
The data is in a fixed width 80-column format.
Here is the sort command:
What I am trying to do is sort on the first 13-digit number (absolute characters 8-20, inclusive) and then the last number, way off to the right (absolute characters 78-80, inclusive).
My sort command + arguments isn't doing what I want it to do. Can anyone spot the problem? It seems to be taking into consideration the Character before the 13-digit number. It doesn't really make sense.
Is there a way to sort, specifying keys by absolute position? Rather than worry about sort's interpretation of fields? Also, I wonder if there is a way to have sort show the user exactly what the keys are, as interpreted from the arguments. That might help the trouble shooting process.
Any help is greatly appreciated!
--jim
I'm a perl guy, and not really a stranger to unix, not a guru either (about to be obvious).
I'm needing to sort some data, and I'm getting screwy results. I'll post a line or two of notional data, and then the sort command I'm using.
Notional Data: (substitut dashes for spaces; s/-/ /g
Code:
--3---W1234537831234--EA00001--BLAHBLAHBLAH----------------------------------223
--3---W1234537841234--EA00001--BLAHBLAHBLAH----------------------------------013
--3---W1234637891234--EA00001--BLAHBLAHBLAH----------------------------------123
--3---W1834537891234--EA00001--BLAHBLAHBLAH----------------------------------023
Now imagine have a gig's worth of data (single file) in that shape that needs to be sorted.
The data is in a fixed width 80-column format.
Here is the sort command:
Code:
sort -y - n -k 2.2,2 -k 5.1,5 file.txt
My sort command + arguments isn't doing what I want it to do. Can anyone spot the problem? It seems to be taking into consideration the Character before the 13-digit number. It doesn't really make sense.
Is there a way to sort, specifying keys by absolute position? Rather than worry about sort's interpretation of fields? Also, I wonder if there is a way to have sort show the user exactly what the keys are, as interpreted from the arguments. That might help the trouble shooting process.
Any help is greatly appreciated!
--jim