Path: utzoo!attcan!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: regexp..prepending a line globally (Vi) Message-ID: <7047@star.cs.vu.nl> Date: 2 Jul 90 15:12:50 GMT References: <1772@island.uu.net> Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Informatika, Amsterdam, The Netherlands Lines: 42 In article <1772@island.uu.net>, daniel@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)