sorting and reversing lines of a file
David Fiander
david at hcr.UUCP
Wed Feb 1 03:59:27 AEST 1989
In article <9056 at burdvax.PRC.Unisys.COM> lang at 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.
<Sanity check: I'm about to think of something Doug Gwyn hasn't>
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 <<EOF
*> > 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"
More information about the Comp.unix.questions
mailing list