Path: utzoo!attcan!uunet!jarthur!usc!cs.utexas.edu!ut-emx!ibmchs!auschs!d75!panda.uucp!eli From: eli@panda.uucp (Eli Taub/100000) Newsgroups: comp.editors Subject: Re: regexp..prepending a line globally (Vi) Keywords: ed, ex, vi Message-ID: <3236@d75.UUCP> Date: 3 Jul 90 15:16:00 GMT References: <1772@island.uu.net> Sender: news@d75.UUCP Reply-To: eli@panda.uucp (Eli Taub/100000) Organization: IBM AWD, Austin, TX Lines: 41 Cross posting from comp.unix.questions: In article <1772@island.uu.net> daniel@island.uu.net (Daniel Smith - OPD Gang) writes: > > All my years in vi and this one stumps me! I wanted >to make a real quick shell script, taken from the output >of an ls-lR on uunet. So, I get these lines: > >/usr/spool/ftp/comp.sources.unix/volume22/nn6.4: >part01.Z >part02.Z >part03.Z > Stuff deleted ... > >What I want to end up with is: >/usr/spool/ftp/comp.sources.unix/volume22/nn6.4/part01.Z >/usr/spool/ftp/comp.sources.unix/volume22/nn6.4/part02.Z > > Daniel >-- > dansmith@well.sf.ca.us daniel@island.uu.net unicom!daniel@pacbell.com >ph: (415) 332 3278 (h), 491 1000 (w) disclaimer: Island's coffee was laced :-) The real answer should be - use sed, awk and friends, or use `find -print' when possible. But since you asked for it ...: $s/$/^M:/ g/:/s@\(.*\):@,//- s!^!\1/!@\ d a\ *a [ ^M stands for: V ] To use, simply insert the above lines into a file, say exls, and source it like `so' in (ex) command mode: :so exls _ |___ Eli Taub (512) 838-4810 | Who needs emacs when you have vi | | | \ | | | | /\/ Contractor at (AWD) IBM | I express my opinions not IBM's. | / | \