regexp..prepending a line globally (Vi)

Maarten Litmaath maart at cs.vu.nl
Tue Jul 3 01:12:50 AEST 1990


In article <1772 at island.uu.net>,
	daniel at island.uu.net (Daniel Smith - OPD Gang) writes:
)...
)/usr/spool/ftp/comp.sources.unix/volume22/nn6.4:
)part01.Z
)part02.Z
)part03.Z
)part04.Z
).
).
). etc...
)
)	So far so good.  Now what I wanted to do is take the first
)line (with the path) and prepend it to every line with a regexp.  [...]

Not so trivial, I think.  The following sh/sed solution works.
Try to figure it out!
--------------------cut here--------------------
SED='
	/spool/{
: dir
		s/:$/\//
		h
: file
		n
		/spool/b dir
		H
		g
		s/\n//
		p
		x
		s/\n.*//
		x
		b file
	}
	p
'

sed -n "$SED" ls-output-file
--
 "and with a sudden plop it lands on usenet.  what is it? omigosh, it must[...]
   be a new user! quick kill it before it multiplies!"      (Loren J. Miller)



More information about the Comp.unix.questions mailing list