Florian Kulzer wrote: > On Wed, Mar 04, 2009 at 16:24:27 -0500, kamaraju kusumanchi wrote: > > [...] > >> Now, >> I would like to replace all the occurrences of >> >> a(ijk)1b with a(ijk)23b >> a(jik)1b with a(jik)23b >> a(ikj)1b with a(ikj)23b >> and so on for all the strings such as a(???) >> >> Because of the size of the files involved, the number of files on >> which I have to perform this operation I decided to use sed (instead >> of doing it manually in vim) > > [...] > >> Is there any way >> to write something like >> >> s/a(???)1b/a(???)23b/g >> >> where the second ??? is the string matched by the first regular >> expression. > > sed -e 's/a(\(...\))1b/a(\1)23b/g' >
You hit it right on the head. The \1 construct is exactly what I am after. Thanks! BTW, If anyone is interested, I found this great book called sed & awk (2nd Edition), by Dale Dougherty, Arnold Robbins http://www.amazon.com/sed-awk-2nd-Dale-Dougherty/dp/1565922255/ . It's so far the best documentation I read on sed, awk. It also has lots of practical tips. raju -- Kamaraju S Kusumanchi http://malayamaarutham.blogspot.com/ -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org