Xref: utzoo comp.unix.questions:23481 comp.lang.perl:1714 Path: utzoo!attcan!uunet!mcsun!hp4nl!phigate!ehviea!leo From: leo@ehviea.ine.philips.nl (Leo de Wit) Newsgroups: comp.unix.questions,comp.lang.perl Subject: Re: regexp..prepending a line globally (Vi) Message-ID: <822@ehviea.ine.philips.nl> Date: 3 Jul 90 15:11:30 GMT References: <1772@island.uu.net> <7047@star.cs.vu.nl> <8571@jpl-devvax.JPL.NASA.GOV> Reply-To: leo@ehviea.UUCP (Leo de Wit) Organization: Philips I&E Eindhoven Lines: 32 In article <8571@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: |In article <7047@star.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: |: |: Not so trivial, I think. The following sh/sed solution works. |: Try to figure it out! [about 18 lines of sed script omitted] | |Which just goes to show ya... | | Real programmers can write assembly code in any language. :-) :-) :-) | |For those who believe in the waterbed theory of language complexity, |how 'bout: | | #!/usr/bin/perl -p | if (s#^(/.*):\n##) | { $prefix = $1; } | else | { s#^#$prefix/#; } | |Fairly trivial, I think. OK, Larry, you asked for it :-) sed '/spool/h //d G s/\(.*\)\n\(.*\):/\2\/\1/' $* Trivial, indeed. Leo.