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 Message-ID: <3F9448F1.91AFE2F3@dessent.net> Date: Mon, 20 Oct 2003 13:43:29 -0700 From: Brian Dessent Organization: My own little world... X-Accept-Language: en,en-US MIME-Version: 1.0 To: ML CygWIN Subject: Re: OT: Using sed - guru help wanted. References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.linuxsv3.net X-AntiAbuse: Original Domain - cygwin.com X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dessent.net Note-from-DJ: This may be spam 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/