X-Spam-Check-By: sourceware.org Message-ID: <454063A9.5FCA59C2@dessent.net> Date: Thu, 26 Oct 2006 00:28:41 -0700 From: Brian Dessent X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) MIME-Version: 1.0 To: fergus CC: cygwin AT cygwin DOT com Subject: Re: Easy? sed syntax References: <000001c6f8c7$3452f4b0$240210ac AT tcgp DOT dundee DOT ac DOT uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com fergus wrote: > In any string (eg "xaaabababbbxaabbbabx") remove all instances of "ab" and > keep on doing this as long as you can. > > Do it once: > > echo xaaabababbbxaabbbabx | sed 's/ab//g' > xaabbxabbx echo xaaabababbbxaabbbabx | sed -e :a -e 's/ab//' -e ta See section 3.7 of the sed manual. The idiom of ":a ... ta" creates a label 'a' and then branches back to that label (repeating the s///) as long as there was a successful match. Brian -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/