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

Re: grep replacement using sed is behaving oddly



On Fri, Oct 21, 2022 at 01:21:44PM -0400, Gary Dale wrote:
> I'm hoping someone can tell me what I'm doing wrong. I have a line in a lot
> of HTML files that I'd like to remove. The line is:
> 
>             <hr  style="border-top: 1px solid rgb(0, 32, 159); margin:
> 0rem;">
> 
> I'm testing the sed command to remove it on just one file. When it works,
> I'll run it against *.html. My command is:
> 
>  sed -i -s 's/\s*\<hr\ \ style.*\>//g' history.html
> 
> Unfortunately, the replacement doesn't remove the line but rather leaves me
> with:
> 
>             <;">

This looks as if the <> in the regexp were interpreted as left and right
word boundaries (but that would only be the case if you'd given the -E
(or -r) option).

Try explicitly adding the --posix option, perhaps...

And oh, option "-i" implies "-s" according to the docs. But this shouldn't
matter (and much less explain the behaviour you're seeing).

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature


Reply to: