Re: Sort the file

From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 04/30/04

  • Next message: Icarus Sparry: "Re: [cygwin]Please why is it not working ?"
    Date: Fri, 30 Apr 2004 00:11:45 -0400
    
    

    In article <c6scck$fj3gh$1@ID-210011.news.uni-berlin.de>,
     "Chris F.A. Johnson" <c.fa.johnson@rogers.com> wrote:

    > On 2004-04-29, Piyush Bichhoriya wrote:
    > > Hi there
    > > I'am new here and could use some help
    > > I have one file
    > >
    > > L310
    > > L400
    > > L311
    > > L401
    > > H4
    > >
    > > and i want to sort on first character only to
    > >
    > > H4
    > > L310
    > > L400
    > > L311
    > > L401
    > >
    > > I tried many options in sort but nothing is working.
    > > What i need actually to move last line to top without changing the
    > > order of other lines.
    >
    > As I pointed out in comp.lang.awk, you don't need sort:
    >
    > {
    > tail -1 FILE
    > sed '$d' FILE
    > } > NEWFILE

    That will work for the special case of the example file he posted. My
    guess is that he needs a more general solution, where the line that
    needs to be moved is not always the last line.

    -- 
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    

  • Next message: Icarus Sparry: "Re: [cygwin]Please why is it not working ?"

    Relevant Pages

    • Re: How to sort a list of strings on a substring
      ... No, that's incorrect. ... Try it with this data and you will see it fails: ... *not* how to sort the list according to the first character '1'. ...
      (comp.lang.python)
    • Re: Attn: Marshall Barton
      ... right did not make any difference in the sort order. ... find first number, find first character, find first number after first ... I think we are gilding the lily. ... the right mid if some other portions are missing. ...
      (microsoft.public.access.reports)
    • Re: Attn: Marshall Barton
      ... right did not make any difference in the sort order. ... find first number, find first character, find first number after first ... I think we are gilding the lily. ... the right mid if some other portions are missing. ...
      (microsoft.public.access.reports)
    • Re: sort with special order
      ... >>> I need to sort them so they are in order of Q, B, then Z>>> ... select the first character of the string and prepend ...
      (perl.beginners)
    • Re: Attn: Marshall Barton
      ... right did not make any difference in the sort order. ... apparently ambiguous mix of alphas, digits, the dot/dash and ... There's even one example where the middle portion is not all ... find first number, find first character, find first number after first ...
      (microsoft.public.access.reports)