[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sed numbered fields don't start from parenthesis
From: |
blind Pete |
Subject: |
Re: sed numbered fields don't start from parenthesis |
Date: |
Sun, 2 Nov 2014 11:32:52 +1100 |
On Thu, 02 Oct 2014 06:53:21 -0600
Eric Blake <address@hidden> wrote:
> On 10/02/2014 06:41 AM, blind Pete wrote:
> > Hi,
> >
> > I believe that the output from the following should be "Sep", not
> > "28th_Sep". The result can be changed by adding a ".*" to the
> > start of the search string, but I don't think that that should be
> > necessary. Removing the trailing ".*" also produces odd results.
>
> Sorry, but the behavior you see is mandated by POSIX, and not a bug.
I was completely wrong.
Could the man pages me made more obvious by adding a line like,
"Note: only matched sections are processed, others are passed though
unchanged.".
If you get a lot of misguided bug reports, that could reduce the
noise.
Sorry for the inconvenience. Thank you for the good work.
> > Using Ubuntu 12.04 LTS.
> >
> > $ echo 28th_September_2014 | sed "s/\(sep\).*/\1/i"
>
> The s/// command has two steps: first, find the matching portion of
> the entire line:
>
> 28th_September_2014
> ^^^^^^^^^^^^^^
>
> then replace the portion of the line that matched with the
> substitution string:
>
> 28th_Sep
>
> You _do_ have to use .* on both front and end of the pattern if you
> want to shorten an entire line down to just a matched backref number.
--
testing
bP
signature.asc
Description: PGP signature
- Re: sed numbered fields don't start from parenthesis,
blind Pete <=