You can't do it in vi without resorting to some macro trickery. (Of
course, the vi hackers will now come out of the woodwork to prove me
wrong... after all, this *is* Usenet. :-)
In Perl, it'd be:
perl -ne 'if (/^(.*):$/) { $pre = $1; } else { print "$pre/$_"; }'
Just another Perl hacker,
--
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III |
| mer...@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/
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.
Larry Wall
lw...@jpl-devvax.jpl.nasa.gov
P.S. It's not your fault, Maarten--if you push a waterbed down in one spot,
it just naturally goes up somewhere else.
OK, Larry, you asked for it :-)
sed '/spool/h
//d
G
s/\(.*\)\n\(.*\):/\2\/\1/' $*
Trivial, indeed.
Leo.
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