delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/10/20/18:25:34

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Message-ID: <F76C9B2DA2FC4C4CA0A18E288BBCBCF7D6DBFE@nihexchange24.nih.gov>
From: "Buchbinder, Barry (NIH/NIAID)" <BBuchbinder AT niaid DOT nih DOT gov>
To: "'Hannu E K Nevalainen'" <garbage_collector AT telia DOT com>,
ML CygWIN
<cygwin AT cygwin DOT com>
Subject: RE: Using sed - guru help wanted.
Date: Mon, 20 Oct 2003 18:25:14 -0400
MIME-Version: 1.0

How about

$ echo ' a b / c d e ' | \
  sed -e 's/ *\(.*\) *\/ *\(.*\) */.\1.\2./' \
      -e 's/ \./\./g'

-----Original Message-----
From: Hannu E K Nevalainen [mailto:garbage_collector AT telia DOT com] 
Sent: Monday, October 20, 2003 3:11 PM
To: ML CygWIN
Subject: OT: Using sed - guru help wanted.


$ echo ' a b / c d e ' | od -w8 -t x1z
0000000 20 61 20 62 20 2f 20 63  > a b / c<
0000010 20 64 20 65 20 0a        > d e .<
0000016

$ 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

/Hannu E K Nevalainen - almost nuts again ;-P
-- printf("Timezone: %s\n", (DST)?"UTC+02":"UTC+01"); --
--END OF MESSAGE--


--
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/

--
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