This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Easy? sed syntax
- From: Brian Dessent <brian at dessent dot net>
- To: fergus <fergus at bonhard dot uklinux dot net>
- Cc: cygwin at cygwin dot com
- Date: Thu, 26 Oct 2006 00:28:41 -0700
- Subject: Re: Easy? sed syntax
- References: <000001c6f8c7$3452f4b0$240210ac@tcgp.dundee.ac.uk>
- Reply-to: 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/