Re: sort on single item only



Lao Ming wrote:
On Mar 30, 10:40 am, Martin Trautmann <t-...@xxxxxxx> wrote:
On Mon, 30 Mar 2009 10:32:24 -0700 (PDT), Lao Ming wrote:
On Mar 30, 2:00 am, pk <p...@xxxxxxxxxx> wrote:
On Monday 30 March 2009 07:02, Lao Ming wrote:
What if the column delimiters were either spaces or, say, tildes.
Could it still be done?
Man sort, option -t
Well, that's not quite what I meant. Of course, now that I think
about it, what I meant was probably just wishful thinking. For the
most part, the fields look like this:
1234 ABC 56 one-large-text-field
However, they can also look like this (below) since the first field is
actually five chars, the 2nd field is actually four chars. The 3rd
field, however, is always just two chars.
1234~ABC~56 one-large-text-field
If it can be done, I'd still really love to know how.
What's your sort field?

You want to sort by 56?

sort -t"~" -k3,3

I do not understand yet where POS1 starts counting - I would expect one
less instead. But that's something which sort can do very well.

- Martin

No, the data looks like this:

1234~ABC~56 one-large-text-field
4321 ZYX 65 more text
2009~FTP 21 still more text

Thus, the first five characters are always field 1, the next 4 chars
are always field 2, columns 10-11 are always field 3 and 13 and beyond
are always field 4.




sort -t<char_NOT_in_records> -k 1.1,1.5 -k 1.6,1.9 -k 1.10,1.11 -k 1.12
.



Relevant Pages

  • Re: Regarding Opening a 1GB File for Processing.
    ... >its a text file each record is of 100 chars, ... i need to sort the ... >file based in the first field, ... A local SQL server would be another (possibly ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Sorting Alpha then Numeric
    ... I had to convert the chars, I used Ascand if numeric add 123, I also ... First field enter: ... You will need three blank fields and enter 3 sort order equations ...
    (microsoft.public.access.reports)
  • Re: Textmate vs. TextWrangler
    ... And then you get a table template that you have to edit. ... 'Ctrl+<' saved me 10 chars every time I wanted to create a table I'd ... TextWrangler has a sort of way to do this using text factories, but flexible support for all that sort of stuff is in BBedit. ...
    (uk.comp.sys.mac)
  • Re: Problems with sort (or any alternatives?)
    ... My input file has four fields. ... each 8 chars in the format of ccyymmdd. ... I wish to sort the input file on either the 1st, ... Given your record structure, "-t '.'" will break the line into two ...
    (comp.os.linux.misc)
  • Re: Regarding Opening a 1GB File for Processing.
    ... its a text file each record is of 100 chars, ... file based in the first field, ... first two fields and sort the list, ... >to do during the sorting. ...
    (microsoft.public.dotnet.framework.performance)