Path: utzoo!attcan!uunet!island!daniel From: daniel@island.uu.net (Daniel Smith - OPD Gang) Newsgroups: comp.unix.questions Subject: regexp..prepending a line globally (Vi) Message-ID: <1772@island.uu.net> Date: 1 Jul 90 20:00:46 GMT Reply-To: daniel@island.uu.net (Daniel Smith - OPD Gang) Organization: Island Graphics, Marin County, California Lines: 37 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 part04.Z . . . etc... So far so good. Now what I wanted to do is take the first line (with the path) and prepend it to every line with a regexp. I know how to do this quickly by hand and all that, but thought I should be able to do this easily with something like: :g/\(.*spool.*\)/s/^part/\1\/part/g which is wrong. 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 I'll do it by hand this time, but I'd really like to know "how to capture a pattern on a given line, and then apply it on other lines that match another pattern". Thanks for any help. Oh, and before we get into editor wars...I am trying to learn GNU Emacs...it's just hard to make the shift after 8 years of vi ;-) 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 :-)