sorting and reversing lines of a file

Francois-Michel Lang lang at pearl.PRC.Unisys.COM
Fri Jan 27 00:13:44 AEST 1989


I need utilities to do two things:
(1) reverse the order of lines in a file
    but leave the lines themselves intact.
    The Unix utility does just the opposite of this.

    E.g., if the file "f" contains
       line1 
       line2
       line3
    I want to produce
       line 3
       line 2
       line 1
    I have an awk program to do this,
    but I'm sure some clever soul out there can do much better.

(2) sort a file by length of input lines.
    Again, I have a script to do this which uses awk, sort, and sed,
    but I'm sure it can be done better.

I'd prefer no C programs!
Many thanks.
----------------------------------------------------------------------------
Francois-Michel Lang
Paoli Research Center, Unisys Corporation lang at prc.unisys.com (215) 648-7256
Dept of Comp & Info Science, U of PA      lang at cis.upenn.edu  (215) 898-9511



More information about the Comp.unix.questions mailing list