Hannu E K Nevalainen wrote:

> $ echo ' a b / c d e ' | \
>   sed -e 's/ *\(.*\) *\/ *\(.*\) */.\1.\2./'
> .a b .c d e .
> 
> I want the output to be '.a b.c d e.' - that is; strip out the trailing
> spaces.
> 
> HOW do I achieve that?  ( \s = any ws, \S = any non ws )
> 
> Obviously \(.*\) grabs/includes the last space. My brain has stoppped
> working, so right now I can't work around that :-I

Personally, I can't stand the "basic" style regexps that sed uses, and I
prefer perl-compatible.  You can use the non-greedy modifier, for
example:

command | perl -pe 's!^ +(.*) +/ +(.*?) +$!.\1.\2.!'

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/

Reply via email to