Re: a two-level 'sort' question

From: Bill Marcum (bmarcum_at_iglou.com.urgent)
Date: 03/29/05


Date: Tue, 29 Mar 2005 15:04:55 -0500

On 29 Mar 2005 09:13:37 -0800, subPlanck@excite.com
  <subPlanck@excite.com> wrote:
>
> Bill Seivert 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.
> [...]
>> 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
>
> This works the way I wanted it to work, thanks, but what made 'sort'
> change its separator from an underscore to a space in the M term?

The separator doesn't have to change. "-k 1.1M,1.3" tells sort to look
at only the first three characters, and likewise for the other -k
expressions. Only the "-k 2.1,2.5" depends on the separator.

-- 
"I deleted a file from my PC last week and I have just realized that I
need it. If I turn my system clock back two weeks will I have my file
back again?"


Relevant Pages

  • Re: output from cut command
    ... I still wouldn't bother with the pipe to sort though since ... > it's trivial to just use awk to print the unique lines, ... The for will produce the unique records but they are not ... Bill Seivert ...
    (comp.unix.questions)
  • Re: a two-level sort question
    ... Bill Seivert wrote: ... This works the way I wanted it to work, thanks, but what made 'sort' ... change its separator from an underscore to a space in the M term? ... are the separator change/cancellation rules in 'sort'? ...
    (comp.unix.questions)
  • Re: Is there any method to detect change in system clock?
    ... Changing the system clock ... May be some place where such sort of log might be maintained and we can ... you had such evidence, how would you prove that it had not been tampereed ... Gary L. Smith ...
    (microsoft.public.windows.file_system)
  • Re: [SLE] 9.3 cron.daily run time
    ... Op zaterdag 7 mei 2005 21:53, schreef Ken Schneider: ... there has to be some sort of check against the ... > system clock whether it is set correctly or not. ...
    (SuSE)
  • Re: slrn and wildcards in the scorefile
    ... I guess the SLRN format seems to be a sort of de ... I bought and have partially completed the O'Reilly "Mastering Regular ... Expressions". ...
    (news.software.readers)