regexp..prepending a line globally (Vi)
Larry Wall
lwall at jpl-devvax.JPL.NASA.GOV
Wed Jul 4 06:42:21 AEST 1990
In article <822 at ehviea.ine.philips.nl> leo at ehviea.UUCP (Leo de Wit) writes:
: In article <8571 at jpl-devvax.JPL.NASA.GOV> lwall at 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
More information about the Comp.unix.questions
mailing list