Path: utzoo!attcan!lsuc!ncrcan!hcr!david From: david@hcr.UUCP (David Fiander) Newsgroups: comp.unix.questions Subject: Re: sorting and reversing lines of a file Keywords: sort reverse Message-ID: <4832@hcr.UUCP> Date: 31 Jan 89 17:59:27 GMT References: <9056@burdvax.PRC.Unisys.COM> Reply-To: david@zeus.UUCP (David Fiander) Organization: HCR Corporation, Toronto Lines: 40 In article <9056@burdvax.PRC.Unisys.COM> lang@pearl.UUCP writes: > >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. If you don't need the file reversing as a filter, which it in practice won't behave as anyway, then ed will do just what you want: Script started on Tue Jan 31 12:47:35 1989 $ cat demo line 1 line 2 line 3 line 4 line 5 $ ed demo < > g/^/m0 *> > w *> > q *> > EOF 35 35 $ cat demo line 5 line 4 line 3 line 2 line 1 $ script done on Tue Jan 31 12:48:56 1989 Pretty nifty, eh? -------- David Fiander (...!hcr!david) "Jolt: All the sugar and twice the caffeine of the leading colas"