On 2022-10-21 at 14:15, Greg Wooledge wrote:

> So... yeah, \< and/or \> clearly have some special meaning to GNU
> sed. Good luck figuring out what that is.

'info sed', section 'sed regular expressions', subsection 'regular
expression extensions':

>> '\<'
>>      Matches the beginning of a word.
>> 
>>           $ echo "abc %-= def." | sed 's/\</X/g'
>>           Xabc %-= Xdef.
>> 
>> '\>'
>>      Matches the end of a word.
>> 
>>           $ echo "abc %-= def." | sed 's/\>/X/g'
>>           abcX %-= defX.

IOW, each seems to be half of the usual '\b' (edge of a word) set. With
the default sed behavior (not sure whether that's basic regular
expressions or extended regular expressions, in the nomenclature of the
info document), you can use replace the latter with an alternation of
both of the former:

echo 'a b c' | sed 's/\(\<\|\>\)b\b//'
a  c
echo 'a b c' | sed 's/\bb\b//'
a  c

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to