Reversing a file?
Chris Torek
chris at mimsy.UUCP
Sat Oct 14 21:20:25 AEST 1989
In article <39 at minya.UUCP> jc at minya.UUCP (John Chambers) writes:
>... g/^/m0 ...
>It's curious that when I used "1,$" instead of "g/^/", it didn't work.
>I wonder if this is a general ed failing, or if it's just here.
It is a feature.
`g/pat/cmd' applies `cmd' to each line matching `pat'---meaning each
line is examined one at a time, and if it matches, `cmd' is done.
`1,$cmd', however, applies `cmd' to the range 1,$.
It should become obvious what is going on: The first command moves line
1 after line 0, then (what was, and here still is) line 2 after line 0,
and then moves line 3 after 0, and so forth. The second moves all the
lines, as a single unit, to after line 0.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at cs.umd.edu Path: uunet!mimsy!chris
More information about the Comp.unix.questions
mailing list