Re: sed numbered fields don't start from parenthesis

blind Pete <[email protected]> Sun, 2 Nov 2014 11:32:52 +1100
Newsgroups gmane.comp.gnu.utils.bugs
Message-ID <20141102113252.16675145@PPlive>
On Thu, 02 Oct 2014 06:53:21 -0600
Eric Blake <[email protected]> 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 (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAlRVe7QACgkQwRfXamhmx78bCQCfXgR9PDItW6R7xOLiYKVEm0uT
yHoAn2wsHKToANYOqSTjIsDWhHDpj++Z
=hwAT
-----END PGP SIGNATURE-----