delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/10/26/03:28:57

X-Spam-Check-By: sourceware.org
Message-ID: <454063A9.5FCA59C2@dessent.net>
Date: Thu, 26 Oct 2006 00:28:41 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: fergus <fergus AT bonhard DOT uklinux DOT net>
CC: cygwin AT cygwin DOT com
Subject: Re: Easy? sed syntax
References: <000001c6f8c7$3452f4b0$240210ac AT tcgp DOT dundee DOT ac DOT uk>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019