Xref: utzoo comp.unix.questions:23487 comp.lang.perl:1718 Path: utzoo!attcan!uunet!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.unix.questions,comp.lang.perl Subject: Re: regexp..prepending a line globally (Vi) Message-ID: <8583@jpl-devvax.JPL.NASA.GOV> Date: 3 Jul 90 20:42:21 GMT References: <1772@island.uu.net> <7047@star.cs.vu.nl> <8571@jpl-devvax.JPL.NASA.GOV> <822@ehviea.ine.philips.nl> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 28 In article <822@ehviea.ine.philips.nl> leo@ehviea.UUCP (Leo de Wit) writes: : In article <8571@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: : | #!/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. That's fine if you're not dyslexic about slashes and backslashes. If you're gunnin' for the shortest command, try this one on for size: perl -ne '/:/||print"$`/$_"' $* (I'll freely admit that if the contest were to double space a file, sed would win easily.) Larry