Re: a two-level 'sort' question

From: Bill Seivert (seivert_at_pcisys.net)
Date: 03/26/05

  • Next message: TompoeS: "unix file system(s)"
    Date: Fri, 25 Mar 2005 19:31:23 -0700
    
    

    Barry Margolin wrote:
    > In article <1111785861.926694.303320@l41g2000cwc.googlegroups.com>,
    > subPlanck@excite.com wrote:
    >
    >
    >>I'm stuck trying to sort a long list of files in the form:
    >>
    >>Feb 24 13:50 060399_20a08.124
    >>Feb 22 12:06 060399_20a09.035
    >>Feb 22 12:06 060399_20a09.034
    >>
    >>whereby the entries are first sorted/grouped by
    >>sort -t_ -d -k 2.1,2.5
    >>and each block is sorted in an ascending order by date.
    >>
    >>man sort gives the following example to sort
    >> 30 December
    >> 23 MAY
    >> 25 June
    >> 10 June
    >>sort -k 2M -k 1n
    >>but I want to keep sorted blocks after the undersore as priority
    >>blocks.
    >>
    >>The way I see it, the problem is in having to switch filed separators,
    >>an underscore and space, in the same sort expresasion. Can it be done?
    >>
    >>I'd appreciate any suggestions, because none of my attempts have been
    >>successful.
    >
    >
    > Use -k 1.1,1,12 to specify the second field to be just the 12 characters
    > containing the date and time.
    >
    But that will sort April and August in front of February.

    Try:
    sort -t_ -d -k 2.1,2.5 -k 1.1M,1.3 -k 1.5n,1.6 -k 1.7n,1.8 -k 1.10n,1.11
    -k 1.14n,1.19

    Bill Seivert


  • Next message: TompoeS: "unix file system(s)"

    Relevant Pages

    • Re: a two-level sort question
      ... > whereby the entries are first sorted/grouped by ... > and each block is sorted in an ascending order by date. ... > man sort gives the following example to sort ... > but I want to keep sorted blocks after the undersore as priority ...
      (comp.unix.questions)
    • a two-level sort question
      ... I'm stuck trying to sort a long list of files in the form: ... whereby the entries are first sorted/grouped by ... but I want to keep sorted blocks after the undersore as priority ...
      (comp.unix.questions)
    • Re: Sorting Problem in Report
      ... That is a proper sort for a text field that is storing number characters. ... You must set the sort order in the report. ... ascending order. ...
      (microsoft.public.access.gettingstarted)
    • Re: Browsing the newly messed up Archive.org (continued)
      ... Orlando Enrique Fiol wrote: ... This gives you all the shows from that year in ascending order, ... That then grays out the same sort by ... I ain't a friend to change." ...
      (rec.music.gdead)
    • Sort and then cut records to Cut records and then sort
      ... cut out the records first and then sort them in ascending order. ... out the following code but fail to item into items code. ... sort in ascending order first, and then cut the records out ...
      (microsoft.public.outlook.program_vba)