bug-sed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#19414: bug in sed


From: Buchs, Kevin J.
Subject: bug#19414: bug in sed
Date: Fri, 19 Dec 2014 15:56:52 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

I am using sed, version 4.2.1 on a few different systems. What I have discovered is that inside a substitute command, a space alone is magically anchored at the start of the line in an anti-greedy match.

As an example, consider this input stream:

 a                     <-- leading space
b c
d  e
f    g


Along with these one-liner invocations:

sed -e 's/ *//'
sed -e 's/[ ]*//'
sed -e 's/[[:space::]]*//'
sed -e 's/ ?//'
sed -e 's/ +//'

What seems to be happening is that the wildcard match gets anchored to the beginning of the line with a zero character hit.

This case seems to apply not only to spaces but other characters.

--
Kevin Buchs   Research Computer Services   Phone: 507-538-5459
Mayo Clinic   200 1st. St SW   Rochester, MN 55905   http://mayoclinic.org






reply via email to

[Prev in Thread] Current Thread [Next in Thread]