Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.questions Subject: Re: Reversing a file? Message-ID: <20176@mimsy.UUCP> Date: 14 Oct 89 11:20:25 GMT References: <39@minya.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 18 In article <39@minya.UUCP> jc@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@cs.umd.edu Path: uunet!mimsy!chris