This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Easy? sed syntax


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]